Home > Software design >  Spring Boot 3 with Lombok
Spring Boot 3 with Lombok

Time:12-30

After I upgraded my project from Spring Boot 2.7 to 3.0 I am getting

cannot find symbol

compiler errors because of Lombok generated code.

Is there any way to make it work together - Spring Boot 3 and Lombok annotations.

CodePudding user response:

You can leave it to Spring to manage the Lombok version.

Here's an example if you're using Maven:

<dependencies>
    <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
    </dependency>
</dependencies>


<build>
    <finalName>project-name</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>17</source>
                <target>17</target>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>

Run mvn clean install on your terminal to test it.

CodePudding user response:

You should update to the lattest version of lombok 1.18.24 which runs without problems with spring-boot-3.0.1

  <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.24</version>
    </dependency>

Problem is not occuring actually from spring-boot but from jdk since spring-boot-3 requires as minimum jdk17 and older versions of lombok are not compatible with jdk17 or newer.

As can be seen from changelog lombok 1.18.22 is the first version compatible with jdk17.

  • Related