Search code examples
javaspringspring-bootmavenlombok

Upgrading to Spring Boot 3 causing annotation processing errors


I am in the process of upgrading our existing application from Spring Boot 2.7.8 to 3.0.13. The core Spring Boot library is being pulled in through a custom common library our team uses. I'm using IntelliJ 2022.1.2 Ultimate Edition (for Mac), JDK 17, and Lombok. When compiling my POM, I get multiple errors similar to this:


    <file location>:[85,69] error: cannot find symbol
        symbol:   method getRuleName()
        location: class RuleManagerDto

...and this:


    <file location>:[9,64] error: cannot find symbol
        symbol:   class ResultBuilder
        location: class Result

The errors start after this line in the compiling process: maven-compiler-plugin:3.8.1:compile (default-compile)... I'm assuming the issue is related to annotation processing, specifically the @Data and @Builder annotations. I've tried the following things to address the issue:

  • added the following code under the maven-compiler-plugin element:

    <annotationProcessorPaths>
        <path>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.24</version>
        </path>
        <path>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct-processor</artifactId>
            <version>1.6.0</version>
        </path>
        <path>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-mapstruct-binding</artifactId>
            <version>0.2.0</version>
        </path>
    </annotationProcessorPaths>

  • used <annotationProcessorPath> in place of <path> above
  • updated Lombok dependency to v1.18.24 ans v1.18.36
  • updated Maven compiler plugin to v3.8.1
  • added <optional> property to Lombok dependency
  • added <forceJavacCompilerUse>true</forceJavacCompilerUse>
  • changed all Lombok imports to use "*" vs. actual class names
  • added <scope>provided</scope> to Lombok dependency

None of these potential remedies have fixed the problem. I am invalidating the cache and restarting after every attempted fix. I am also using the update switch when compiling: mvn clean -U install. My colleague has suggested that the problem is with a related library that is out of date, which is plausible. However, I'm not getting any errors other than the types listed above, so I have no idea which library it could be.


Solution

  • The annotation processing errors have been eliminated. In the POM, I changed <springdoc.version>1.6.0</springdoc.version> to <springdoc.version>1.8.0</springdoc.version>. One of my coworkers found this fix. I'm not sure where he came up with it, so I can't point to a source. I'm receiving many new errors, but at least these ones are fixed. Thanks to everyone who responded.