Can't compile project when I'm using Lombok under IntelliJ IDEA
I have fixed it in IDEA 12 by setting check box Enable annotation processing
in:
Settings -> Compiler -> Annotation Processors
For IDEA 2016.2:
Preferences... > Build, Execution, Deployment > Compiler > Annotation Processors
After enabling, run Build -> Rebuild Project to have annotations recognized and eliminate errors.
For IDEA 2019.2.1, depending on how the project is configured, installing the Project Lombok plugin may not be sufficient. Here is another way to use Project Lombok with IntelliJ IDEA:
- Visit https://projectlombok.org/download
- Download the JAR file into the project lib directory (e.g.,
$HOME/dev/java/project/libs
). - Start the IDE.
- Click File Settings.
- Expand Build, Execution, Deployment Compiler Annotation Processors.
- Ensure Enable annotation processing is checked.
- Ensure Store generates sources relative to is selected based on the project's module settings (if Module output directory doesn't work, come back and try the other setting).
- Click Apply.
- Click Plugins.
- Click Marketplace.
- Set search field to:
lombok
- Install Lombok.
- Click OK.
- Restart the IDE if prompted.
- Click File Project Structure.
- Select Libraries.
- Click the + symbol to add a new project library (or press Alt+Insert).
- Select Java.
- Set the path to:
$HOME/dev/java/project/libs/lombok.jar
- Click OK.
- Select the modules to apply.
- Click OK.
- Optionally, rename
lombok
toProject Lombok 1.18.8
. - Click OK.
The project can now import from the lombok
package and use Project Lombok annotations (e.g., lombok.Setter
and lombok.Getter
).
Can't compile project with Lombok in IntelliJ IDEA
Here are the steps:
- I updated the lombok plugin version:
File -> Settings -> Plugins -> Updates
- Restart IDE.
- Download the lombok JAR
- Run this command:
mvn install:install-file -DgroupId=org.projectlombok -DartifactId=lombok -Dversion=1.1.18 -Dpackaging=jar -Dfile=/path/to/file
IntelliJ IDEA cannot see Lombok generated code
You need to enable the annotation preprocessor.
See documentation here.
Additionally you should install the lombok plugin if not done already
java: You aren't using a compiler supported by lombok, so lombok will not work and has been disabled
Using lombok 1.18.16 did not work for me. I added the argument below in the build process VM options in
-Djps.track.ap.dependencies=false
Setting:-
Build, Execution, Deployment -> Compiler -> Shared build process VM
options
and it worked
https://github.com/rzwitserloot/lombok/issues/2592
Can't compile project when I'm using Lombok under IntelliJ IDEA
I have fixed it in IDEA 12 by setting check box Enable annotation processing
in:
Settings -> Compiler -> Annotation Processors
For IDEA 2016.2:
Preferences... > Build, Execution, Deployment > Compiler > Annotation Processors
After enabling, run Build -> Rebuild Project to have annotations recognized and eliminate errors.
For IDEA 2019.2.1, depending on how the project is configured, installing the Project Lombok plugin may not be sufficient. Here is another way to use Project Lombok with IntelliJ IDEA:
- Visit https://projectlombok.org/download
- Download the JAR file into the project lib directory (e.g.,
$HOME/dev/java/project/libs
). - Start the IDE.
- Click File Settings.
- Expand Build, Execution, Deployment Compiler Annotation Processors.
- Ensure Enable annotation processing is checked.
- Ensure Store generates sources relative to is selected based on the project's module settings (if Module output directory doesn't work, come back and try the other setting).
- Click Apply.
- Click Plugins.
- Click Marketplace.
- Set search field to:
lombok
- Install Lombok.
- Click OK.
- Restart the IDE if prompted.
- Click File Project Structure.
- Select Libraries.
- Click the + symbol to add a new project library (or press Alt+Insert).
- Select Java.
- Set the path to:
$HOME/dev/java/project/libs/lombok.jar
- Click OK.
- Select the modules to apply.
- Click OK.
- Optionally, rename
lombok
toProject Lombok 1.18.8
. - Click OK.
The project can now import from the lombok
package and use Project Lombok annotations (e.g., lombok.Setter
and lombok.Getter
).
Lombok added but getters and setters not recognized in Intellij IDEA
I fixed it by ticking the "Enable annotation processing" checkbox in Settings->Compiler->Annotation Processors.
Along with this you might also need to install lombok
plugin as mentioned in @X.Chen's answer for new versions of IntelliJ Idea.
Related Topics
Add Jar Files to a Spark Job - Spark-Submit
How to Load Classes at Runtime from a Folder or Jar
The Performance Impact of Using Instanceof in Java
Seeking Useful Eclipse Java Code Templates
Using Sleep() for a Single Thread
Easiest Way to Merge a Release into One Jar File
Java: Ternary with No Return. (For Method Calling)
How to Use 3Des Encryption/Decryption in Java
Java Nio Filechannel Versus Fileoutputstream Performance/Usefulness
Processbuilder: Forwarding Stdout and Stderr of Started Processes Without Blocking the Main Thread
Can Java 8 Code Be Compiled to Run on Java 7 Jvm
Where Is Java_Home on MACos Mojave (10.14) to Lion (10.7)
Why Java Classes Do Not Inherit Annotations from Implemented Interfaces