admin管理员组

文章数量:1023744

I consider that my maven has problems with the annotation @Data from lombok.

About the project: Java 23 Spring Boot Version 3.3.4 also using Intellij ultimate

The error appears after like mvn compile or when I started the application:

 COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /*/controller/ImageController.java:[25,16] Symbol doesn't found
  Symbol: Method getImages()
  Location: Variable request from Typ *.dto.ImageUploadRequest
[ERROR] */controller/ImageController.java:[30,67] Symbol doesn't found
  Symbol: Method getDataURL()
  Location: Variable image from Typ *.entity.Image

I tried serveral methods.The logic is btw works.After serervall restarts this error appears. In Terminal:

mvn clean; mvn compile; mvn install; mvn clean install

POM but it didn't help

<plugin>
   <groupId>.projectlombok</groupId>
   <artifactId>lombok-maven-plugin</artifactId>
   <version>1.18.20.0</version>
 </plugin> `This snippet from stackoverflow`

I tried to write the boiler code and yes it works but That is not the way I would walk. My user looks like this:

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@Entity
@Data
@NoArgsConstructor
@RequiredArgsConstructor
@Table(name = "player")
public class User {
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Integer id;
   @NonNull
   private String name;
   @NonNull
   private Integer score;

} 

My pom looks like this:

<properties>
    <java.version>23</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>3.3.4</version>
    </dependency>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>3.3.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
    </dependency>
    <dependency>
        <groupId>.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.30</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <classifier>spring-boot</classifier>
                        
                      <mainClass>*.ZoomOutApiApplication</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <version>1.18.20.0</version>
        </plugin>
    </plugins>
</build>

I consider that my maven has problems with the annotation @Data from lombok.

About the project: Java 23 Spring Boot Version 3.3.4 also using Intellij ultimate

The error appears after like mvn compile or when I started the application:

 COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /*/controller/ImageController.java:[25,16] Symbol doesn't found
  Symbol: Method getImages()
  Location: Variable request from Typ *.dto.ImageUploadRequest
[ERROR] */controller/ImageController.java:[30,67] Symbol doesn't found
  Symbol: Method getDataURL()
  Location: Variable image from Typ *.entity.Image

I tried serveral methods.The logic is btw works.After serervall restarts this error appears. In Terminal:

mvn clean; mvn compile; mvn install; mvn clean install

POM but it didn't help

<plugin>
   <groupId>.projectlombok</groupId>
   <artifactId>lombok-maven-plugin</artifactId>
   <version>1.18.20.0</version>
 </plugin> `This snippet from stackoverflow`

I tried to write the boiler code and yes it works but That is not the way I would walk. My user looks like this:

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@Entity
@Data
@NoArgsConstructor
@RequiredArgsConstructor
@Table(name = "player")
public class User {
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Integer id;
   @NonNull
   private String name;
   @NonNull
   private Integer score;

} 

My pom looks like this:

<properties>
    <java.version>23</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>3.3.4</version>
    </dependency>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>3.3.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
    </dependency>
    <dependency>
        <groupId>.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.30</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <classifier>spring-boot</classifier>
                        
                      <mainClass>*.ZoomOutApiApplication</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <version>1.18.20.0</version>
        </plugin>
    </plugins>
</build>
Share Improve this question asked Nov 18, 2024 at 20:24 JoFJoF 437 bronze badges 6
  • Did you follow the steps in their setup page? projectlombok./setup/maven – blurfus Commented Nov 18, 2024 at 20:30
  • looks like it could not find a symbol at ImageController class - 30,67 – catch32 Commented Nov 18, 2024 at 20:33
  • The newest version of Lombok is 1.18.36. Make sure to update to that. You might also want to try adding <arg>-proc:full</arg> to the <compilerArgs> (in the maven-compiler-plugin). – dan1st Commented Nov 18, 2024 at 21:44
  • Add the maven-compiler-plugin and add lombok as a dependency to the compiler as well. Your dependencies are also flawed for using Spring boot. Assuming you have the parent remove the version from your dependencies you currently have, to let Spring Boot mange the proper compatible version (and you are now even mixing modules from at least 2 Spring Boot versions!). – M. Deinum Commented Nov 19, 2024 at 6:59
  • @dan1st I followed your advices and now it's working. Just updated the lobock. thank you so much <3 – JoF Commented Nov 19, 2024 at 7:20
 |  Show 1 more comment

2 Answers 2

Reset to default 2

Lombok commonly breaks with (major) Java updates due to relying on unsupported APIs/unsafe operations. To deal with that, the developers of Lombok provide updates whenever a new Java version breaks it.

In your case, you specified version 1.18.30 which was released in September 2023 which Java 23 was released in September 2024. So, to run Lombok with Java 23, you should update to the latest version which is 1.18.36 (at the time of writing). In the changelog, you can also see JDK 23 support mentioned for that version.

    <dependency>
        <groupId>.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.36</version>
    </dependency>

It also seems like you are using the lombok-maven-plugin. I think this shouldn't be necessary for most purposes unless you are delomboking for any reason.

Apart from that annotation processing has been disabled by default in JDK 23 so you would need to use -proc:full as a compiler argument to add annotation processing. In Maven, you can do this using the maven-compiler-plugin:

<build>
    <plugins>
        <plugin>
            <groupId>.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <proc>full</proc>
            </configuration>
        </plugin>
    </plugins>
</build>

Instead of <proc>full</proc>, you can also use <compilerArgs> with an argument containing -proc:full:

<build>
    <plugins>
        <plugin>
            <groupId>.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <compilerArgs>
                    <arg>-proc:full</arg>
                </compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>

Dan's answer didn't work for me, but somehow doing my own thing worked. I'm putting it here for anybody else with the same problem:

What worked for me is to put the following into Build in my pom.xml:


<build>
        <plugins>
            <plugin>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>.projectlombok</groupId>
                <artifactId>lombok-maven-plugin</artifactId>
                <version>1.18.20.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>delombok</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

I consider that my maven has problems with the annotation @Data from lombok.

About the project: Java 23 Spring Boot Version 3.3.4 also using Intellij ultimate

The error appears after like mvn compile or when I started the application:

 COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /*/controller/ImageController.java:[25,16] Symbol doesn't found
  Symbol: Method getImages()
  Location: Variable request from Typ *.dto.ImageUploadRequest
[ERROR] */controller/ImageController.java:[30,67] Symbol doesn't found
  Symbol: Method getDataURL()
  Location: Variable image from Typ *.entity.Image

I tried serveral methods.The logic is btw works.After serervall restarts this error appears. In Terminal:

mvn clean; mvn compile; mvn install; mvn clean install

POM but it didn't help

<plugin>
   <groupId>.projectlombok</groupId>
   <artifactId>lombok-maven-plugin</artifactId>
   <version>1.18.20.0</version>
 </plugin> `This snippet from stackoverflow`

I tried to write the boiler code and yes it works but That is not the way I would walk. My user looks like this:

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@Entity
@Data
@NoArgsConstructor
@RequiredArgsConstructor
@Table(name = "player")
public class User {
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Integer id;
   @NonNull
   private String name;
   @NonNull
   private Integer score;

} 

My pom looks like this:

<properties>
    <java.version>23</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>3.3.4</version>
    </dependency>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>3.3.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
    </dependency>
    <dependency>
        <groupId>.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.30</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <classifier>spring-boot</classifier>
                        
                      <mainClass>*.ZoomOutApiApplication</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <version>1.18.20.0</version>
        </plugin>
    </plugins>
</build>

I consider that my maven has problems with the annotation @Data from lombok.

About the project: Java 23 Spring Boot Version 3.3.4 also using Intellij ultimate

The error appears after like mvn compile or when I started the application:

 COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /*/controller/ImageController.java:[25,16] Symbol doesn't found
  Symbol: Method getImages()
  Location: Variable request from Typ *.dto.ImageUploadRequest
[ERROR] */controller/ImageController.java:[30,67] Symbol doesn't found
  Symbol: Method getDataURL()
  Location: Variable image from Typ *.entity.Image

I tried serveral methods.The logic is btw works.After serervall restarts this error appears. In Terminal:

mvn clean; mvn compile; mvn install; mvn clean install

POM but it didn't help

<plugin>
   <groupId>.projectlombok</groupId>
   <artifactId>lombok-maven-plugin</artifactId>
   <version>1.18.20.0</version>
 </plugin> `This snippet from stackoverflow`

I tried to write the boiler code and yes it works but That is not the way I would walk. My user looks like this:

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@Entity
@Data
@NoArgsConstructor
@RequiredArgsConstructor
@Table(name = "player")
public class User {
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Integer id;
   @NonNull
   private String name;
   @NonNull
   private Integer score;

} 

My pom looks like this:

<properties>
    <java.version>23</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>3.3.4</version>
    </dependency>
    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>3.3.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
    </dependency>
    <dependency>
        <groupId>.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.30</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <classifier>spring-boot</classifier>
                        
                      <mainClass>*.ZoomOutApiApplication</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <version>1.18.20.0</version>
        </plugin>
    </plugins>
</build>
Share Improve this question asked Nov 18, 2024 at 20:24 JoFJoF 437 bronze badges 6
  • Did you follow the steps in their setup page? projectlombok./setup/maven – blurfus Commented Nov 18, 2024 at 20:30
  • looks like it could not find a symbol at ImageController class - 30,67 – catch32 Commented Nov 18, 2024 at 20:33
  • The newest version of Lombok is 1.18.36. Make sure to update to that. You might also want to try adding <arg>-proc:full</arg> to the <compilerArgs> (in the maven-compiler-plugin). – dan1st Commented Nov 18, 2024 at 21:44
  • Add the maven-compiler-plugin and add lombok as a dependency to the compiler as well. Your dependencies are also flawed for using Spring boot. Assuming you have the parent remove the version from your dependencies you currently have, to let Spring Boot mange the proper compatible version (and you are now even mixing modules from at least 2 Spring Boot versions!). – M. Deinum Commented Nov 19, 2024 at 6:59
  • @dan1st I followed your advices and now it's working. Just updated the lobock. thank you so much <3 – JoF Commented Nov 19, 2024 at 7:20
 |  Show 1 more comment

2 Answers 2

Reset to default 2

Lombok commonly breaks with (major) Java updates due to relying on unsupported APIs/unsafe operations. To deal with that, the developers of Lombok provide updates whenever a new Java version breaks it.

In your case, you specified version 1.18.30 which was released in September 2023 which Java 23 was released in September 2024. So, to run Lombok with Java 23, you should update to the latest version which is 1.18.36 (at the time of writing). In the changelog, you can also see JDK 23 support mentioned for that version.

    <dependency>
        <groupId>.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.36</version>
    </dependency>

It also seems like you are using the lombok-maven-plugin. I think this shouldn't be necessary for most purposes unless you are delomboking for any reason.

Apart from that annotation processing has been disabled by default in JDK 23 so you would need to use -proc:full as a compiler argument to add annotation processing. In Maven, you can do this using the maven-compiler-plugin:

<build>
    <plugins>
        <plugin>
            <groupId>.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <proc>full</proc>
            </configuration>
        </plugin>
    </plugins>
</build>

Instead of <proc>full</proc>, you can also use <compilerArgs> with an argument containing -proc:full:

<build>
    <plugins>
        <plugin>
            <groupId>.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <compilerArgs>
                    <arg>-proc:full</arg>
                </compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>

Dan's answer didn't work for me, but somehow doing my own thing worked. I'm putting it here for anybody else with the same problem:

What worked for me is to put the following into Build in my pom.xml:


<build>
        <plugins>
            <plugin>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>.projectlombok</groupId>
                <artifactId>lombok-maven-plugin</artifactId>
                <version>1.18.20.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>delombok</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

本文标签: javaBuild Failure Data Annotation won39t regonize by MavenStack Overflow