Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok annotations do not compile under Intellij idea [duplicate]

  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
like image 235
yurnom Avatar asked Jun 03 '14 04:06

yurnom


People also ask

How do I enable annotation processing in Lombok IntelliJ?

Lombok plugin[Preference->plugins->browse repositories->search 'lombok'->install and restart idea. Preference ->search 'annotation'->enter annotation processor ->enable annotation processing.

Why Lombok is not working in Eclipse?

Eclipse 2020-12 (Eclipse 2020-12 Java) does not support Lombok. It runs fine, but the IDE shows errors for all Lombok generates getters/setters. The previous version of Eclipse work fine. You have to install lombok on your installation, otherwise Eclipse will not be able to handle the Lombok-Annotations.

Is Lombok annotation processor?

Lombok uses annotation processing through APT. So, when the compiler calls it, the library generates new source files based on annotations in the originals.


2 Answers

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
like image 77
4 revs, 3 users 45% Avatar answered Oct 26 '22 02:10

4 revs, 3 users 45%


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.

like image 36
Juraj Misur Avatar answered Oct 26 '22 02:10

Juraj Misur