Lombok @Data error

I'm getting this error
java: cannot find symbol
symbol: method getFirstName()
location: variable customerDto of type dto.CustomerDto
java: cannot find symbol
symbol: method getFirstName()
location: variable customerDto of type dto.CustomerDto
in this part of code:
private Customer mapToCustomer(CustomerDto customerDto) throws Exception {
if(customerDto.getFirstName().isEmpty() || customerDto.getLastName().isEmpty() || customerDto.getEmail().isEmpty() || customerDto.getPassword().isEmpty() || customerDto.getRole().isEmpty()) {
throw new Exception("All fields must be filled");
}

return Customer.builder()
.firstName(customerDto.getFirstName())
.lastName(customerDto.getLastName())
.email(customerDto.getEmail())
.password(customerDto.getPassword())
.role(customerDto.getRole())
.build();
}
private Customer mapToCustomer(CustomerDto customerDto) throws Exception {
if(customerDto.getFirstName().isEmpty() || customerDto.getLastName().isEmpty() || customerDto.getEmail().isEmpty() || customerDto.getPassword().isEmpty() || customerDto.getRole().isEmpty()) {
throw new Exception("All fields must be filled");
}

return Customer.builder()
.firstName(customerDto.getFirstName())
.lastName(customerDto.getLastName())
.email(customerDto.getEmail())
.password(customerDto.getPassword())
.role(customerDto.getRole())
.build();
}
even though I've used the @Data annotation in my CustomerDto class:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CustomerDto {
private Long id;
private String firstName;
private String lastName;
private String role;
private String email;
private String password;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CustomerDto {
private Long id;
private String firstName;
private String lastName;
private String role;
private String email;
private String password;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
11 Replies
JavaBot
JavaBot10h ago
This post has been reserved for your question.
Hey @IamMax420! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
ayylmao123xdd
ayylmao123xdd10h ago
does it work if you annotate it with @getter and @setter instead of @data
IamMax420
IamMax420OP10h ago
nope...
ayylmao123xdd
ayylmao123xdd10h ago
whats the error when you annotate with getter
IamMax420
IamMax420OP10h ago
java: cannot find symbol
symbol: method getFirstName()
location: variable customerDto of type dto.CustomerDto
java: cannot find symbol
symbol: method getFirstName()
location: variable customerDto of type dto.CustomerDto
ayylmao123xdd
ayylmao123xdd10h ago
is it underlined in the editor as error or no
IamMax420
IamMax420OP10h ago
it's not
ayylmao123xdd
ayylmao123xdd10h ago
interesting show the lombok setup then in pom
IamMax420
IamMax420OP10h ago
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<optional>true</optional>
</dependency>
ayylmao123xdd
ayylmao123xdd10h ago
show the annotation process thing with lombok
IamMax420
IamMax420OP10h ago
from the settings?

Did you find this page helpful?