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;
}
39 Replies
JavaBot
JavaBot2mo 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
ayylmao123xdd2mo ago
does it work if you annotate it with @getter and @setter instead of @data
IamMax420
IamMax420OP2mo ago
nope...
ayylmao123xdd
ayylmao123xdd2mo ago
whats the error when you annotate with getter
IamMax420
IamMax420OP2mo 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
ayylmao123xdd2mo ago
is it underlined in the editor as error or no
IamMax420
IamMax420OP2mo ago
it's not
ayylmao123xdd
ayylmao123xdd2mo ago
interesting show the lombok setup then in pom
IamMax420
IamMax420OP2mo 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
ayylmao123xdd2mo ago
show the annotation process thing with lombok
IamMax420
IamMax420OP2mo ago
from the settings?
ayylmao123xdd
ayylmao123xdd2mo ago
yea in pom
IamMax420
IamMax420OP2mo ago
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
ayylmao123xdd
ayylmao123xdd2mo ago
interesting what if you try to comment out the line where it uses the get first name see if it throws an error on the get last name method
IamMax420
IamMax420OP2mo ago
yeah now it just throws an error for the next method .getLastName()
ayylmao123xdd
ayylmao123xdd2mo ago
ok uncomment the get first name method then and show the dto class with getter and setter annotations
IamMax420
IamMax420OP2mo ago
@Getter
@Setter
@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;
}
@Getter
@Setter
@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;
}
ayylmao123xdd
ayylmao123xdd2mo ago
ok so time to change the pom l0l
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source> ur java version
<target>17</target> java version
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version> for testing purposes
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source> ur java version
<target>17</target> java version
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version> for testing purposes
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
IamMax420
IamMax420OP2mo ago
hmm
ayylmao123xdd
ayylmao123xdd2mo ago
oh yea swap the yea swap the part with lombok the first <plugin></plugin>
IamMax420
IamMax420OP2mo ago
aight wow it seems to work now
ayylmao123xdd
ayylmao123xdd2mo ago
😱 incredible right
IamMax420
IamMax420OP2mo ago
yea wht did you change
ayylmao123xdd
ayylmao123xdd2mo ago
ur pom file
IamMax420
IamMax420OP2mo ago
in the <plugin> tf
ayylmao123xdd
ayylmao123xdd2mo ago
yea
IamMax420
IamMax420OP2mo ago
u use lombok yourself? or nah
ayylmao123xdd
ayylmao123xdd2mo ago
yes but i dont use @data annotation
IamMax420
IamMax420OP2mo ago
ok but why did it not work with this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
and worked with this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source> ur java version
<target>17</target> java version
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version> for testing purposes
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source> ur java version
<target>17</target> java version
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version> for testing purposes
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
ayylmao123xdd
ayylmao123xdd2mo ago
well you can see here the version is specified also target and source you need to specify lombok version afaik
IamMax420
IamMax420OP2mo ago
bruh spring initializer is ass in that case
ayylmao123xdd
ayylmao123xdd2mo ago
yea kinda
IamMax420
IamMax420OP2mo ago
giving incomplete xml plugins and all but thanks for helping me out
JavaBot
JavaBot2mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
ayylmao123xdd
ayylmao123xdd2mo ago
gif for u l0l
IamMax420
IamMax420OP2mo ago
I just starred it will keep that in mind lmao
ayylmao123xdd
ayylmao123xdd2mo ago
amazing
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?