Lombok @Data annotation problem

I have this DTO:
@Data
@Builder
public class UserDto {
private Long id;
private String firstName;
private String lastName;
private String email;
private String password;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
@Data
@Builder
public class UserDto {
private Long id;
private String firstName;
private String lastName;
private String email;
private String password;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
and I'm using it in a controller like this:
@PostMapping("/add-user")
public ResponseEntity<String> addUser(@RequestBody UserDto userDto) throws Exception {
try {
if (userDto.getFirstName().isEmpty() || userDto.getLastName().isEmpty() || userDto.getEmail().isEmpty() || userDto.getPassword().isEmpty()) {
throw new Exception("Missing fields while adding a user.");
}
@PostMapping("/add-user")
public ResponseEntity<String> addUser(@RequestBody UserDto userDto) throws Exception {
try {
if (userDto.getFirstName().isEmpty() || userDto.getLastName().isEmpty() || userDto.getEmail().isEmpty() || userDto.getPassword().isEmpty()) {
throw new Exception("Missing fields while adding a user.");
}
but I'm getting an error:
→ moviewatchlist: build failed At 11.04.2025 19:13 with 13 errors
>
UserController.java
moviewatchlist\src\main\java\com\max420\moviewatchlist\controllers 4 errors
→ cannot find symbol method getFirstName() :24
O cannot find symbol method getLastName() :24
O cannot find symbol method getEmail() :24
O cannot find symbol method getPassword() :24
UserService.java
moviewatchlist\src\main\java\com\max420\moviewatchlist\services\impl 9 errors
→ moviewatchlist: build failed At 11.04.2025 19:13 with 13 errors
>
UserController.java
moviewatchlist\src\main\java\com\max420\moviewatchlist\controllers 4 errors
→ cannot find symbol method getFirstName() :24
O cannot find symbol method getLastName() :24
O cannot find symbol method getEmail() :24
O cannot find symbol method getPassword() :24
UserService.java
moviewatchlist\src\main\java\com\max420\moviewatchlist\services\impl 9 errors
11 Replies
JavaBot
JavaBot2w 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
ayylmao123xdd2w ago
can you show the pom file with lombok config
IamMax420
IamMax420OP2w ago
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.max420</groupId>
<artifactId>moviewatchlist</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>moviewatchlist</name>
<description>no desc</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.max420</groupId>
<artifactId>moviewatchlist</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>moviewatchlist</name>
<description>no desc</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
ayylmao123xdd
ayylmao123xdd2w ago
did you add any annotation processor tag for lombok
IamMax420
IamMax420OP2w ago
what's that I have annotation processing enabled that's all I know man I can't fucking do it with spring initializr anymore last time I was doing java I had some other issue with the pom file
IamMax420
IamMax420OP2w ago
Yeah I did "reload all maven projects" but it didn't work, surprisingly
ayylmao123xdd
ayylmao123xdd2w ago
did you add the annotation processor tag just copy the solution from that last thread and it should work make sure to use mvn clean install too
@PostMapping("/add-user")
public ResponseEntity<String> addUser(@RequestBody UserDto userDto) throws Exception {
try {
if (userDto.getFirstName().isEmpty() || userDto.getLastName().isEmpty() || userDto.getEmail().isEmpty() || userDto.getPassword().isEmpty()) {
throw new Exception("Missing fields while adding a user.");
}
@PostMapping("/add-user")
public ResponseEntity<String> addUser(@RequestBody UserDto userDto) throws Exception {
try {
if (userDto.getFirstName().isEmpty() || userDto.getLastName().isEmpty() || userDto.getEmail().isEmpty() || userDto.getPassword().isEmpty()) {
throw new Exception("Missing fields while adding a user.");
}
the code inside this method should be in a separate service not in a controller
IamMax420
IamMax420OP2w ago
alright, I''ll take care of that you mean this?
<build>
<plugins>
<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>
<build>
<plugins>
<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>
ayylmao123xdd
ayylmao123xdd2w ago
ye
JavaBot
JavaBot7d 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?