-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Spring boot does not work with Lombok - Compilation error -Werror #1339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
When I remove lombok dependency it compiles fine. So is the issue with spring or lombok or somewhere else. |
may be its related to #1194 |
My project uses SpringBoot, and it works perfect with Lombok so far...
|
@beamofsoul : Thanks for your reply. I did create a new mvn java project without any Spring dependencies in it. I am getting compilation error for @FunctionalInterface annotation. So this proves that there is nothing to do with Spring here. Looks like Lombok issue. |
Sounds more like a java version or classpath issue |
I ran into this problem with: lombok 1.16.18 Including lombok as a provided dependency, without even without referencing lombok in java source, causes compile to fail if java source contains @FunctionalInterface:
I didn't see a warning in the output, just the compilation error. Removing -Werror or removing lombok resolves the problem. |
I seem to be experiencing the same problem as @nguyenquoc which sounds like it may not be the same as what is reported in the issue, so perhaps it is a different issues. It fails only during the test-compile phase of my project which seems likely because I am guessing I have a JUnit5 test with a
Is it helpful to open a separate issue for this? I am not using Spring in this project. |
Hmm, I cannot reproduce the problem. Input filessrc/main/java/HelloWorld.java @lombok.Data
public class HelloWorld {
int foo;
public static void main(String... args) {
System.out.println(new HelloWorld().getFoo());
}
@FunctionalInterface
interface Foo {
String name();
}
}
lombok.config lombok.addJavaxGeneratedAnnotation = false
pom.xml <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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>lombok-jdk9</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.9</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<fork>true</fork>
<compilerargs>
<arg>-Werror</arg>
<arg>-Xlint:all</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-opens=-Jjdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
</compilerargs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Outputs
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building lombok-jdk9 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lombok-jdk9 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /shared/maven/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ lombok-jdk9 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /shared/maven/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.745 s
[INFO] Finished at: 2017-10-19T22:19:08Z
[INFO] Final Memory: 9M/23M
[INFO] ------------------------------------------------------------------------
0
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T19:39:06Z)
... |
I got this using Gradle. Unknown key 'lombok.addLombokGeneratedAnnotation' |
I was able to solve similar issues in my gradle spring-boot multi-project like so: dependencies {
annotationProcessor("org.projectlombok:lombok")
compileOnly("org.projectlombok:lombok")
} Regards, |
I found the same problem with lombok vs Junit5: junit-team/junit5-samples@master...alxn:alun/lombok
|
In the new version of I had the same issue in the version of see my configuration (pom.xml):
and the Entity:
Result:
|
Maven project with -Werror compiler option
COMPILATION WARNING :
No processor claimed any of these annotations: org.springframework.context.annotation, lombok.Data
COMPILATION ERROR :
warnings found and -Werror specified
Maven compiler plugin:
Same issue was reported before at following link Issue1117 tried solutions provided in there but does not work.
The text was updated successfully, but these errors were encountered: