1

I am trying to migrate from Java 8 to Java 11. My versions are as follows:

  1. OpenJDK 11
  2. Springboot: 2.2.7.RELEASE
  3. Maven home: 3.6.1
  4. Lombok: 1.18.12

Everything builds fine. Although I wanted to create a jre using jlink so I need to generate a module-info.java file. I generated it using the STS ide. I just right click on the project -> Configure -> Create module-info.java. When I did this, I can't build the project anymore. It throws a cannot find symbol error for the lines of code that calls @Data annotation of Lombok.

I've tried adding the annotationProcessorPaths tags as stated here: solution but it still does not work. I also tried adding the static keyword like this: enter image description here but it still does not work.

This is what my pom looks like now:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <source>11</source>
        <target>11</target>
        <compilerVersion>11</compilerVersion>
        <annotationProcessorPaths>
            <annotationProcessorPath>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.12</version>
            </annotationProcessorPath>
            <path>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>1.3.0.Final</version>
            </path>
        </annotationProcessorPaths>
        <compilerArguments>
            <AaddGeneratedAnnotation>false</AaddGeneratedAnnotation>
            <Adebug>true</Adebug>
        </compilerArguments>
    </configuration>
</plugin>

I've been searching for the whole day for a solution but I still can't find one that works for me. Any other suggestions that I can try?

Thank you in advance!

Rocky
  • 429
  • 1
  • 9
  • 26
  • I had the same issue with lombok, but adding `static` worked for me for some reason (I'm using Gradle with the badass-jlink plugin). – thorin9000 Jun 26 '22 at 22:06

1 Answers1

1

Instead of the plugin section that I've posted in the question, I just transformed it into this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>11</source>
        <target>11</target>
        <annotationProcessorPaths>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.12</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

and it returned a build successful.

Rocky
  • 429
  • 1
  • 9
  • 26