Lombok annotations not compiled on Intellij idea

  • I installed the plugin for the intellij idea (lombok-plugin-0.8.6-13).
  • Added by lombok.jar in classpath
  • I can find getters and setters in the structure window. And Intellij shows no errors.
  • Customization - Lombok plugin - proven Intellij configuration for Lombok, it shows that "IntelliJ configuration seems to be in order."

Everything seems to be in order. But when I compile the test, errors occur: the getXXX and setXXX methods cannot be found.

I opened the .class file with IntelliJ and found out that there are no setXXX and getXXX methods.

Can someone 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
+139
java intellij-idea lombok
Jun 03 '14 at 4:05
source share
11 answers

To solve the problem, install:

  • Preferences ( Ctrl + Alt + S )
    • Assembly, execution, deployment
      • compiled
        • Annotation processors
          • Enable annotation processing

Make sure you have the Lombok plugin for IntelliJ installed!

  • Settings -> Plugins
  • Search for "Lombok Plugin"
  • Click Browse Repositories ...
  • Choose the Lombok plugin
  • set
  • Restart IntelliJ
+278
Dec 11 '14 at 19:36
source share

If you use the Eclipse compiler with lombok, this setting finally worked for me:

  • IDEA 14.1
  • Lombok plugin
  • ... / Compiler / Java Compiler> Using the Compiler: Eclipse
  • ... / Compilers / Annotation Handlers> Enable Annotation Processing: checked (default setting)
  • ... / Compiler> Additional VM build options: -javaagent: lombok.jar

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

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

+37
May 08 '15 at
source share

For me, both the Lombok plugin and annotation processing are necessary, no. There is no need to use Eclipse and the additional options -javaagent: lombok.jar .

  • Idea 14.1.3, build 141.1010
  • Lombok plugin [Preference-> plugins-> browse repositories-> search for 'lombok' → install and restart the idea.
  • Preference → search “annotation” → enter annotation handler → enable annotation processing.
+10
Oct 25 '15 at 13:56
source share

IDEA 2016.1:

  • Install the lombok plugin
  • Settings → Compiler → Annotation processors → Enable annotation processing: checked (default setting)
  • Settings -> Compiler -> Annotation handlers -> Annotation handlers add "lombok.launch.AnnotationProcessorHider $ AnnotationProcessor"
  • Also, if you use maven, add maven-compiler-plugin -> annotationProcessors -> annotationProcessor: lombok.launch.AnnotationProcessorHider $ AnnotationProcessor to the configuration

     <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> 
+8
Jun 15 '16 at 15:48
source share

Ensure that these two requirements are met:

  • Enable annotation processing,

    Settings> Build, Run, Deploy> Compiler> Annotation Handlers> Enable Annotation Processing

  • The Lombok plugin is installed and enabled for your project.

+7
03 Oct '16 at 22:24
source share

None of the extended answers to this question solved the problem for me.

I managed to solve the problem by adding the lombok dependency to 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

I hope my answer will be useful to you

+6
Feb 05 '17 at 20:43
source share

After troubleshooting too long, I found a simple solution that ensures that IntelliJ handles Lombok annotations correctly during build.

The gradle-lombok plugin is not needed for this workaround. For your build.gradle , only the following is required:

 dependencies { compileOnly("org.projectlombok:lombok:1.16.18") } 

The workaround is to enable the following IntelliJ setup:

  1. Open IntelliJ Settings / Preferences.
  2. Go to Build, Execute, Deployment > Build Tools > Gradle > Runner
  3. Check the box Delegate IDE build/run actions to gradle " Delegate IDE build/run actions to gradle


The advantages of this workaround over other solutions on this page:

  • Annotation processing is not required!
  • Able to use the Java compiler of your choice (no Eclipse compiler)
  • Do not use buggy-plugin-plugin-lombok (although maybe someone else can solve this)
  • No virtual machine parameters
  • No hard-coded paths to the Lombok bank

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

+6
Dec 29 '17 at 12:25
source share

If you are using Intellij on a Mac, this setting finally worked for me.

Installations: Intellij

  1. Go to the "Settings" section, find "Plugins".
  2. Enter "Lombok" in the plugins search box. Lombok is an unrelated plugin, so it will not be displayed at first.
  3. Click Browse to find unrelated plugins.
  4. A "Lombok plugin" should appear. Select it.
  5. Click the green Install button.
  6. Click the "Restart Intellij IDEA" button.

Settings:

  1. Enable annotation handler

    • Go to settings -> assembly, execution, deployment -> settings -> compiler -> annotation handlers
    • File → Other Settings → Default Settings → Compiler → Annotation Handlers
  2. Check if Lombok plugin is enabled

    • IntelliJ IDEA-> Settings → Other Settings → Lombok Plugin → Enable Lombok
  3. Add the Lombok jar to the global libraries and project dependencies.

    • File → Project Structure → Global Libraries (Add lombok.jar)
  4. File → Project structure → Project settings → Modules → “Dependencies” tab = check for breaking

  5. Restart Intellij

+4
Sep 18 '18 at 18:48
source share

In Itellij 15 CE, it is enough to install Lombok Plugin (without additional configuration).

+3
Jul 11 '16 at 10:50
source share

I followed this procedure to get a similar / same error.

mvn idea: clean

mvn idea: idea

After that, I was able to compile from both the intellij IDE and the command line.

+2
Nov 16 '18 at 10:28
source share

I cannot get this to work with the javac compiler and I am getting the same error.

Error: (9, 14) java: lombok package does not exist

I turned on the annotation processor, and also tried to rebuild the project, invalidate the cache / restart. Does not help.

However, I tried to partially work with the eclipse compiler. I say partly because, although the assembly is successful, the editor still complains about “Cannot resolve character”.

Idea - community publication 15.04 Lombok - 1.16.6 Lombok plugin ( https://github.com/mplushnikov/lombok-intellij-plugin ) - 0.9.8 JDK - 1.8.0_51

Update: Well, I finally got this job. Mine was a gradle project, and the lomb was set up as a normal "provided" configuration. Worked fine after adding this to build.gradle

 idea { module { scopes.PROVIDED.plus += [configurations.provided] } } 

So 3 steps

  • Install the Lombok plugin from the menu File-> Settings-> Plugins
  • Enable annotation handler (javac compiler works)
  • Make sure you have build.gradle or pom.xml updated for the idea if you add lombok as a custom configuration.
0
Mar 10 '16 at 4:20
source share



All Articles