264
  1. I've installed the plugin for intellij idea(lombok-plugin-0.8.6-13).
  2. Added lombok.jar into classpath
  3. I can find getters and setters in the window of structure. And Intellij shows no error.
  4. Setting - Lombok plugin - Verified Intellij configuration for lombok, it shows that "configuration of IntelliJ seems to be ok".

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?

  • plugin:lombok-plugin-0.8.6-13
  • lombok.jar:1.14.0
  • idea:13.0.2 for linux
  • jdk:1.7.0_21
yurnom
  • 2,641
  • 2
  • 12
  • 4
  • 30
    Finally, I solve the problem.Setting - Compiler - Annotation Processors - Enable annotation processing. Make sure it was checked! – yurnom Jun 03 '14 at 08:04
  • 2
    After banging my head against the wall for an extended period of time, I realised it was because my project SDK was mistakenly set to Java 11, which appears to not work well with Lombok. Setting it back to Java 8 did the trick for me. – Chris Neve Oct 04 '19 at 10:28
  • 1
    In addition to enabling annotation processing, for me I had to check the option "Obtain processors from project classpath" instead of the list of Processsor path. – Nicholas Reis Dec 24 '20 at 22:31

11 Answers11

489

In order to solve the problem set:

  • Preferences (Ctrl + Alt + S)
    • Build, Execution, Deployment
      • Compiler
        • Annotation Processors
          • Enable annotation processing

Make sure you have the Lombok plugin for IntelliJ installed!

  • Preferences -> Plugins
  • Search for "Lombok Plugin"
  • Click Browse repositories...
  • Choose Lombok Plugin
  • Install
  • Restart IntelliJ
mike
  • 4,929
  • 4
  • 40
  • 80
  • 7
    When I click on Build -> Rebuild project whenever I am using Eclipse compiler to compile java sources inside intellij Idea lombock annotations are not processed and project has numerous compile time errors. Swithed back to Javac compiler and everything works fine. – David Feb 13 '15 at 08:01
  • 4
    File -> Settings -> Build, Execution, Deployment -> ... if you're on Windows – appoll Apr 14 '16 at 09:19
  • 9
    I had the reverse problem, enabled annotation processing, but hadn't yet installed the plugin! – Nick Grealy May 17 '16 at 07:43
  • 1
    Try updating plugin as well. – Witold Kaczurba Oct 26 '17 at 12:23
  • 1
    Once you have enabled annotation processing, you may need to clean and rebuild your project. – Patrice Jul 09 '18 at 12:05
54

If you're using Eclipse compiler with lombok, this setup finally worked for me:

  • IDEA 14.1
  • Lombok plugin
  • ... / Compiler / Java Compiler > Use Compiler: Eclipse
  • ... / Compiler / Annotation Processors > Enable annotation processing: checked (default configuration)
  • ... / Compiler > Additional build process VM options:(Shared build process VM options) -javaagent:lombok.jar

The most important part is the last one, mine looks like following: enter image description here

Plugin is needed for IntelliJ editor to recognize getters and setters, javaagent is needed for eclipse compiler to compile with lombok.

Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81
Juraj Misur
  • 1,338
  • 1
  • 11
  • 7
  • 16
    In my Intellij IDEA 2016.1 the option "Additional build process VM options" are named as "Shared build process VM options". – Igor Bljahhin Jan 15 '17 at 15:44
35

If you're using Intellij on Mac, this setup finally worked for me.

Installations: Intellij

  1. Go to Preferences, search for Plugins.
  2. Type "Lombok" in the plugin search box. Lombok is a non-bundled plugin, so it won't show at first.
  3. Click "Browse" to search for non-bundled plugins
  4. The "Lombok Plugin" should show up. Select it.
  5. Click the green "Install" button.
  6. Click the "Restart Intellij IDEA" button.

Settings:

  1. Enable Annotation processor

    • Go to Preferences -> Build, Execution,Deployment -->Preferences -> Compiler -> Annotation Processors
    • File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
  2. Check if Lombok plugin is enabled

    • IntelliJ IDEA-> Preferences -> Other Settings -> Lombok plugin -> Enable Lombok
  3. Add Lombok jar in Global Libraries and project dependencies.

    • File --> Project Structure --> Global libraries (Add lombok.jar)
  4. File --> Project Structure --> Project Settings --> Modules --> Dependencies Tab = check lombok

  5. Restart Intellij

17

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.

Bongo
  • 333
  • 3
  • 12
12

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:

  1. Open IntelliJ preferences/settings.
  2. Navigate to Build, Execute, Deployment > Build Tools > Gradle > Runner
  3. Check the box labeled Delegate IDE build/run actions to gradle


Benefits of this workaround compared to other solutions on this page:

  • No annotation processing necessary!
  • Able to use the Java compiler of your choice (no Eclipse compiler necessary)
  • No use of buggy gradle-lombok plugin (although perhaps someone else can solve this)
  • No VM options necessary
  • No hard-coded paths to lombok jar

One downside is that IntelliJ will no longer use its own test runner. Instead, tests are always run through Gradle.

SonnevilleJ
  • 121
  • 1
  • 3
  • True. For some strange reason, even ChatGPT thinks that gradle-lombok plugin is necessary. This should be the accepted answer in year 2023. – Introspective May 08 '23 at 07:32
11

For me, both lombok plugin and annotation processing enable needed, no else. No need to Use Eclipse and additional -javaagent:lombok.jar options.

  • Idea 14.1.3, build 141.1010
  • Lombok plugin[Preference->plugins->browse repositories->search 'lombok'->install and restart idea.
  • Preference ->search 'annotation'->enter annotation processor ->enable annotation processing.
weiheng
  • 346
  • 4
  • 16
  • 1
    Using the eclipse compiler isn't necessary, but there are some compelling reasons you might want to consider it. More info here: http://blog.dripstat.com/why-you-should-use-the-eclipse-compiler-in/ – depsypher Oct 29 '15 at 18:55
10

IDEA 2016.1:

  • Install lombok plugin
  • Settings -> Compiler -> Annotation Processors -> Enable annotation processing: checked (default configuration)
  • Settings -> Compiler -> Annotation Processors -> Annotation Processors add "lombok.launch.AnnotationProcessorHider$AnnotationProcessor"
  • 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>
    
Jan Kubovy
  • 421
  • 5
  • 11
  • 1
    I did the same thing you wrote, except the thing with maven (I don't use build tools right now), but it still doesn't work. Intellij says it cant find the `lombok.launch.AnnotationProcessorHider$AnnotationProcessor` processor. – Stefan B Aug 06 '16 at 10:12
  • After follow these steps, remove Lombok annotation, and puts again. – otaviodecampos Oct 07 '16 at 00:56
8

Make sure these two requirements are satisfied:

  1. Enable annotation processing,

    Preferences > Build, Execution, Deployment > Compiler > Annotation Processors > Enable annotation processing

  2. Lombok plugin is installed and enabled for your project.

Nikhil Katre
  • 2,114
  • 23
  • 22
8

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

KoolKat-Bytes
  • 109
  • 1
  • 3
4

On Itellij 15 CE, it's enough to just install Lombok Plugin (no additional configuration required).

kecso
  • 2,387
  • 2
  • 18
  • 29
1

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

  1. Install Lombok plugin from File->Settings->Plugins
  2. Enable Annotation Processor (javac compiler works too)
  3. Ensure that you have build.gradle or pom.xml updated for idea if you are adding lombok as a custom config.
robbin
  • 1,924
  • 4
  • 20
  • 26