It seems everything is OK. But when I compile a test, errors come: can not find the methods getXXX and setXXX.
I opened the .class file with IntelliJ and find out that there is no setXXX and getXXX methods.
Could somebody tell me why?
This question is related to
java
intellij-idea
lombok
I followed this procedure to get ride of a similar/same error.
mvn idea:clean
mvn idea:idea
After that I could build both from the IDE intellij and from command line.
None of the advanced answers to this question resolved the problem for me.
I managed to solve the problem by adding a dependencie to lombok in the pom.xml file, i.e. :
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
</dependency>
I am using IntelliJ 2016.3.14 with maven-3.3.9
Hope my answer will be helpful for you
I am unable to get this working with the javac compiler, and I get the same error.
Error:(9, 14) java: package lombok does not exist
I have enabled annotation processor, and have also tried rebuilding the project, invalidate cache/restart. Doesn't help.
I did however get it to work partially with eclipse compiler. I say partial because although the build passes successfully, the editor still complains about "Cannot resolve symbol".
Idea - 15.04 community edition Lombok - 1.16.6 Lombok plugin (https://github.com/mplushnikov/lombok-intellij-plugin) - 0.9.8 JDK - 1.8.0_51
Update: Ok, I finally got this working. Mine was a gradle project, and lombok was configured as a custom "provided" configuration. Worked fine after adding this in build.gradle
idea {
module {
scopes.PROVIDED.plus += [configurations.provided]
}
}
So, 3 steps
On Itellij 15 CE, it's enough to just install Lombok Plugin (no additional configuration required).
If you're using Intellij on Mac, this setup finally worked for me.
Installations: Intellij
Settings:
Enable Annotation processor
Check if Lombok plugin is enabled
Add Lombok jar in Global Libraries and project dependencies.
File --> Project Structure --> Project Settings --> Modules --> Dependencies Tab = check lombok
Restart Intellij
Make sure these two requirements are satisfied:
Enable annotation processing,
Preferences > Build, Execution, Deployment > Compiler > Annotation Processors > Enable annotation processing
Lombok plugin is installed and enabled for your project.
After spending far too long troubleshooting this, I found a simple workaround which ensures IntelliJ processes Lombok annotations correctly during builds.
The gradle-lombok plugin is not necessary for this workaround. Your build.gradle
only requires the following:
dependencies {
compileOnly("org.projectlombok:lombok:1.16.18")
}
The workaround is to turn on the following IntelliJ setting:
Build, Execute, Deployment > Build Tools > Gradle > Runner
Delegate IDE build/run actions to gradle
Benefits of this workaround compared to other solutions on this page:
One downside is that IntelliJ will no longer use its own test runner. Instead, tests are always run through Gradle.
In order to solve the problem set:
Make sure you have the Lombok plugin for IntelliJ installed!
->
PluginsIDEA 2016.1:
Also if you are using maven add to maven-compiler-plugin configuration -> annotationProcessors -> annotationProcessor: lombok.launch.AnnotationProcessorHider$AnnotationProcessor
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.plugin.compiler.version}</version>
<configuration>
<compilerVersion>${java.version}</compilerVersion>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessors>
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
For me, both lombok plugin and annotation processing enable needed, no else. No need to Use Eclipse and additional -javaagent:lombok.jar options.
If you're using Eclipse compiler with lombok, this setup finally worked for me:
The most important part is the last one, mine looks like following:
Plugin is needed for IntelliJ editor to recognize getters and setters, javaagent is needed for eclipse compiler to compile with lombok.
Source: Stackoverflow.com