299

I'm trying to use Lombok in my project that I'm developing using IntelliJ IDEA 11.

I've installed 3rd-party plugin for IDEA and it seems working fine because IDEA sees all autogenerated methods/fields.

So I have a class that uses Slf4j. I annotated it like this

import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TestClass
{
 public TestClass()
 {
 log.info("Hello!");
 }
}

But when I build my project compiler spits: cannot find symbol variable log.

Could you please tell me what I'm missing here?

Update: It turned out it's RequestFactory annotation process that fails.

input files: {com.zasutki.courierApp.server.TestServlet, com.mine.courierApp.server.model.DatastoreObject}
annotations: [javax.inject.Singleton, javax.inject.Inject, lombok.Getter, lombok.Setter, com.googlecode.objectify.annotation.Id, com.googlecode.objectify.annotation.OnSave]
Processor com.google.web.bindery.requestfactory.apt.RfValidator matches [lombok.Getter, com.googlecode.objectify.annotation.Id, javax.inject.Inject, lombok.Setter, com.googlecode.objectify.annotation.OnSave, javax.inject.Singleton] and returns false.
cannot find symbol variable log

Any ideas on workarounds?

Update2: Perhaps it's not something readers want to hear but I ended up switching to Kotlin. Do not use Lombok.

asked Feb 24, 2012 at 2:03
5
  • Errors appear even without the plugin. I am not able to run tests of a project if Lombok is in my pom.xml dependencies. Commented Feb 26, 2012 at 21:57
  • there is another answer stackoverflow.com/a/63632563/5410940 Commented Aug 28, 2020 at 11:11
  • Answers below all assume that lombok is working. You may need to add a shared VM option to make that happen. See -stackoverflow.com/a/65188047/529659 Commented Aug 31, 2022 at 22:04
  • This solution solved my problem: stackoverflow.com/a/76157466 Commented Sep 29, 2024 at 6:19
  • "Don't use Lombok" - good advice. There's the answer! Commented Jan 4 at 12:21

52 Answers 52

1
2
530

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:

  1. Visit https://projectlombok.org/download
  2. Download the JAR file into the project lib directory (e.g., $HOME/dev/java/project/libs).
  3. Start the IDE.
  4. Click File 🠖 Settings.
  5. Expand Build, Execution, Deployment 🠖 Compiler 🠖 Annotation Processors.
  6. Ensure Enable annotation processing is checked.
  7. 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).
  8. Click Apply.
  9. Click Plugins.
  10. Click Marketplace.
  11. Set search field to: lombok
  12. Install Lombok.
  13. Click OK.
  14. Restart the IDE if prompted.
  15. Click File 🠖 Project Structure.
  16. Select Libraries.
  17. Click the + symbol to add a new project library (or press Alt+Insert).
  18. Select Java.
  19. Set the path to: $HOME/dev/java/project/libs/lombok.jar
  20. Click OK.
  21. Select the modules to apply.
  22. Click OK.
  23. Optionally, rename lombok to Project Lombok 1.18.8.
  24. Click OK.

The project can now import from the lombok package and use Project Lombok annotations (e.g., lombok.Setter and lombok.Getter).

answered Jan 29, 2013 at 12:09
Sign up to request clarification or add additional context in comments.

16 Comments

Don't forget to set annotation processor: lombok.launch.AnnotationProcessorHider$AnnotationProcessor for both maven-compiler-plugin and Idea (Settings -> Compiler -> Annotation Processors)
This isn't working for me in 2016.2. Maven web project. The only thing that worked was installing the lombok plugin.
in addition to above steps, I had to include the following lines to build.gradle: annotationProcessor "org.projectlombok:lombok:1.18.8" testAnnotationProcessor("org.projectlombok:lombok:1.18.8")
@Gryk after adding your suggestion it worked in my application. Thank you.
@Gryk +1 Solved for me... literally. tried. everything. -.-"
|
94
  1. Make sure it's added correctly to your project.

example for Gradle:

 dependencies {
 compileOnly 'org.projectlombok:lombok:1.18.8'
 annotationProcessor 'org.projectlombok:lombok:1.18.8'
 ...
 }
  1. Install Lombok plugin for your IDE
  2. Check "Enable annotation processing" checkbox in IDE (IntellijIdea), have no idea if there is anything like this for other IDEs like Eclipse.
answered Jul 14, 2019 at 16:42

9 Comments

this, this, and a thousand times this. Thank you, I was stuck for one hour
yep, you are right, we should check the build config first, then IDE setting. thanks a heap!
This is the only thing that actually worked! Why it has only 13 likes?!
God i forgot Gradle added annotationProcessor in newer versions. Thank you for your answer.
After going throgh so many solutions , this worked for me. After adding "annotationProcessor" , everything started working fine.
|
87

Picture representation of resolving this issue.

First enable annotation processors and try. This may or may not work. enter image description here

Post that, you can install the lombok plugin from intellij, (After installation Intellij will restart to enable the plugin, so make sure you save your work.(Intellij does save all the changes before restart, just to be on the safe side.)) screenshot below:

enter image description here

answered Mar 15, 2017 at 12:06

1 Comment

thank you.. I got the same problem. I forgot to install the plugin before I set the Annotation configuration :)
75

Enabling annotation processing will make it work

But if you are on a Mac, make sure you enable annotation processing(tick the checkbox) from both the places available.

1.) Intellij Idea -> Preferences -> Compiler -> Annotation Processors

2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors

answered May 11, 2015 at 8:21

5 Comments

Still had to do this even with the latest intellij 15.0.2
Still present in 15.0.4. I also had to update the Lambok version to the latest and change the Java compiler to JAVAC. Then do a rebuild of the project
Still must do in IntelliJ 2016年1月3日 :) You have to set the 2 annotation processors. Such a pain when you forget about it!
Still must do in IntelliJ 2016.3 :)
even by activating in both places, IntelliJ 2016年3月2日 still fails to compile with Lombok 1.16.12 :(
37

in the latest Gradle version you should use annotationProcessor:

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
answered Jan 29, 2020 at 14:02

1 Comment

It worked for me. I use Kotlin DSL and my code is like this:dependencies { compileOnly("org.projectlombok:lombok:1.18.8") annotationProcessor("org.projectlombok:lombok:1.18.8") ... }
28

I'm using IntelliJ IDEA 2020.3 (Community Edition)

Here, besides install the Lombok plugin and enable annotations (explained by other answers). I also needed to set the flag -Djps.track.ap.dependencies=false to the Build Process Option1.

I didn't need to use the -javaagent approach, neither setup the classpath.

1. Go to: File | Settings | Build, Execution, Deployment | Compiler | "Shared build process VM options" field

References:

answered Dec 22, 2020 at 19:55

1 Comment

Needed to do this on 2021年1月2日
22

Including the following in the pom.xml is what worked for me:

<build>
 <defaultGoal>spring-boot:run</defaultGoal>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <configuration>
 <source>${java.version}</source>
 <target>${java.version}</target>
 <annotationProcessorPaths>
...
 <path>
 <groupId>org.projectlombok</groupId>
 <artifactId>lombok</artifactId>
 <version>${lombok.version}</version>
 </path> 
 </annotationProcessorPaths>
 </configuration>
 </plugin>
</build>
answered Jul 12, 2020 at 18:40

3 Comments

I had to add requires org.slf4j; to mole-info.java also
My error was that I omitted the lombok version line. IntelliJ then, upon autoimporting the POM, configured an annotation processor of lombok-unknown.jar for the module, which was of course not present. Easy fix: Specify the version for plugins!
Don't forget to right click on your pom.xml file and select Reload project from the menu after having added this.
15

Just for reference using IntelliJ 2018.3, I solved this issue (using @Data annotation to insert getter/setter) following the three steps:

  1. File -> Settings -> Build, Execution, Deployment -> Annotation Processors -> Enable Annotation Processing;

enter image description here

Do remember to Apply the change.

  1. Install plugin lombok in the same setting dialog;

enter image description here

  1. It seems good enough for now, it requires to restart IntelliJ and then rebuild your project.

Best wishes :)

answered Feb 19, 2019 at 4:43

3 Comments

Did you had maven or gradle? I am having a problem making lombok work for a multi module project. I keep getting the error: Error:java: Annotation processing is not supported for module cycles. Please ensure that all modules from cycle [module-core,module-utils] are excluded from annotation processing
@0x01Brain I was using maven at that time, but now using gradle instead. As for your question, I do hope you can start a new specific question to describe the details and there are lots of experts out there will help you ;)
never mind I got it to compile now, thanks. I had some conflict in depedencies module-core was imported in utils module and utils module was imported in core module which made a conflict.
10

If you have checked both these steps as follows

  1. Enable annotations : this is a check done in IntelliJ preferences.
  2. Importing lombok into IntelliJ classPath (Preferences -> Plugins)

and still getting errors then please check the compiler - if it is JAVAC or ECLIPSE.

You can check the compiler in Preferences -> Build,Execution,Deployment -> Compiler -> Java Compiler.

Change the Use compiler to Javac (if it is Eclipse). This is what worked for me.

answered Mar 27, 2017 at 13:32

Comments

7

As noted here, quote: "You should activate external compiler option and enable annotation processors or disable external compiler and disable all of annotation compilers to work with lombok". This fixed my problem. Note that I added the Scala plugin prior to receiving this error, so I suspect the plugin changed some of the above settings.

answered Jul 14, 2013 at 8:14

Comments

7

there is a plugin for intellij. see here: https://projectlombok.org/download.html

answered Aug 7, 2015 at 13:45

2 Comments

This plugin can be installed in Settings/Plugins menu of Intellij. Make sure you have the latest plugin installed. Upgrading to latest plugin worked for me.
Also make sure that you have the latest version of IntelliJ installed as well, upgrading solved the issue for me.
5

Do you have lombok as dependency of your project? lombok.jar must be on the classpath during compiling of the project, which is using any of lombok-annotations.

answered Feb 24, 2012 at 20:18

1 Comment

It turned out it fails inside annotation processor. I updated my question with output log.
5

For those of you who are still having trouble:

In addition to the above steps of enabling annotation processors and installing the IntelliJ Lombok plugin, I also had to Build -> Rebuild Project.

answered Aug 21, 2016 at 15:14

1 Comment

I also had to invalidate the cache and restart before Intellij stopped complaining.
5

Lombok version image

Please make sure, you have added the ${lombok.version} in pom.xml or just replace/paste this snippet in pluggins

 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <configuration>
 <annotationProcessorPaths>
 <path>
 <groupId>org.projectlombok</groupId>
 <artifactId>lombok</artifactId>
 <version>${lombok.version}</version>
 </path>
 </annotationProcessorPaths>
 </configuration>
 </plugin>
answered Jan 29 at 18:12

1 Comment

This was the only answer that worked for me.
4

It didn#t work for me with any of the above solutions. I added <scope>provided</scope> to the dependency in pom.xml and it worked.

<dependency>
 <groupId>org.projectlombok</groupId>
 <artifactId>lombok</artifactId>
 <version>1.16.20</version>
 <scope>provided</scope>
 </dependency>
answered Feb 8, 2018 at 20:36

1 Comment

What version of IntelliJ are you using? Also, what JDK version?
3

1、install lombok plugin for IDEA

Intellij Idea -> Preferences -> Plugins -> type in lombok -> Search in Repositories -> install -> restart IDEA

2、 config lombok plugin

Enabling annotation processing will make it work

But if you are on a Mac, make sure you enable annotation processing in the following two places:

Intellij Idea -> Preferences -> Build, Execution, Deployment -> Compiler -> Annotation Processors, check the checkbox of "Enable annotation processing". File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors, check the checkbox of "Enable annotation processing".

answered Dec 7, 2017 at 6:14

1 Comment

I don't see Default Settings in Other Settings in IntelliJ. Are these still present. I am using the Ultimate edition - version11.03
3

I was on Mac

This is my IntelliJ IDEA and Mac Version - IntelliJ IDEA 2017年1月5日 Build #IU-171.4694.70 --- Mac OS X 10.12

In addition to enabling annotation processing (tick the checkbox) at these 2 places.

1.) Intellij IDEA -> Preferences -> Compiler -> Annotation Processors

.

2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors

I had to install Lombok plugin too to make it work.

3.) Intellij IDEA -> Preferences -> Plugins ->Browse Repositories-> Search for "Lombok"-> install plugin -> Apply and restart IDEA

answered Jan 26, 2018 at 22:28

Comments

3

IDEA set wrong jar processor path in this settings for multi-module maven. Correct it or set "Obtain processors from classpath" - the simplest working option

enter image description here

answered Apr 3, 2024 at 16:17

1 Comment

Works, mine was set to some weird C:\Users\nshln\.m2\repository\org\projectlombok\lombok\unknown\lombok-unknown.jar ...
2

Apart from mentioned in all answers I have to add the below code in pom.xml configuration to makes mvn clean install work. Before adding this code I was getting cannot found symbol for getters and setters.

 <annotationProcessorPath>
 <groupId>org.projectlombok</groupId>
 <artifactId>lombok</artifactId>
 <version>1.18.8</version>
 </annotationProcessorPath>
answered May 13, 2020 at 6:57

Comments

2

If you did everything mentioned in this question and It's still failing, don't forget to remove /target folder under your projects. And If it's still failing, restart your IDE. And If it's still failing restart your computer.

answered Oct 25, 2020 at 11:59

Comments

2

I tried enabling lambok, restarted intellij, etc but below worked for me.

Intellij Preferences ->Compiler -> Shared Build process VM Options and set it to

 -Djps.track.ap.dependencies=false

than run

mvn clean install
answered Aug 1, 2022 at 11:53

Comments

2

If you already installed it, then for refresh just deselect and select Enable annotation in Intellij Settings.

answered Oct 19, 2022 at 11:23

Comments

2

My issue was that the bundled version of Lombok plugin in IntelliJ IDEA was incompatible with the version of IntelliJ IDEA itself. I downgraded IntelliJ to 2019年1月4日 and it worked.

enter image description here


it might also be a mess with Java version, Spring, and lombok for higher versions thereof, take a look Compilation error after upgrading to JDK 21 - "NoSuchFieldError: JCImport does not have member field JCTree qualid".

Those are the version I reverted to struggling with Java 23:

<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<java.version>17</java.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<mapstruct-processor.version>0.2.0</mapstruct-processor.version>
<lombok.version>1.18.30</lombok.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>

and it worked. See also this one How to configure Lombok with maven-compiler-plugin?.

answered Jan 20, 2022 at 15:25

Comments

1

Install the below plugin and restart the IDE to resolve the errors:

File -> Settings -> Plugins-> Browse Repositories -> Lombok Plugin

Enable annotation processor:

File -> Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors
File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
answered Sep 21, 2018 at 8:50

Comments

1

I have faced this problem after updating the IDEA to 2018.3. I had to update all the existing plugin

answered Feb 28, 2019 at 9:10

Comments

1

After trying all the suggestions here, I have also find another kind of solution. It seems that sometimes IDEA can not obtain processors from project classpath.

So, on the Annotation Processors settings tab, you have to manually specify Processor path.

answered Feb 11, 2020 at 21:25

Comments

1

For me what worked:

  1. I uninstalled the installed the Lombok plugin freshly
  2. I ticked "Enable Annotation Plugin"
  3. I selected "Obtain processor from the project classpath" in the same page
answered May 16, 2020 at 7:56

Comments

1

For IntelliJ IDEA 2020年1月1日 enabling Kotlin plugin fixed this issue.

answered May 20, 2020 at 9:15

Comments

1

The Jetbrains IntelliJ IDEA editor is compatible with lombok without a plugin as of version 2020.3.

I was using 2020.2 version, i updated to 2020.3 it worked just like that.

answered Feb 17, 2021 at 11:50

Comments

1

I don't think I read my final step in the answers yet. (Mac + IntelliJ Ultimate 2020.1) Its just a silly cause in my case, but those are the ones that can take up most time because the error doesnt directly refer to it.

The same lombok error appeared to me after deleting and recloning the project. After doing the steps mentioned earlier in this thread I still had the error, I then discovered my SKD was defaulted to version 11. I changed this back to 1.8 and everything worked again.

File --> Project Settings --> Project I changed the Project SDK and the Project language level to 1.8

PS the location for the default settings on the mac is different in this IntelliJ version than mentioned before : File --> New Project Settings --> Preferences for new Projects --> Build, Execution, Deployment --> Compiler --> Annotation Processors --> 'check' Enable annotation processing

Hope this helps anybody

answered Mar 9, 2021 at 8:09

Comments

1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.