Lombok is not generating getter and setter

243,939

Solution 1

When starting with a fresh eclipse installation you, in fact, need to "install" Lombok before being able to use it.

  1. Go where you Lombok jar is (e.g. (e.g. you can find in ~/.m2/repository/org/projectlombok/lombok/1.16.10/lombok-1.16.10.jar), run it (Example: java -jar lombok-1.16.10.jar). A window should appear, browse to your eclipse.exe location.
  2. Click on install.
  3. Launch Eclipse, update project configuration on all projects and voila.

Solution 2

  • If you use STS. You must have Lombok installed in your Eclipse by running lombok-xyz.jar

  • Please Try the Following the Steps:

    1. Include pom in Maven .
    2. Exit/Shutdown STS
    3. Find lombok Jar in ~/.m2/repository/org/projectlombok/lombok/version.x
    4. From Command Prompt/Shell java -jar lombok-1.x.y.jar Project Lombok Installer

    5. Start STS

Thats all.

EDIT: I did this and was still showing errors, as mentioned in the comments. So I updated the project: right-click on project -> Maven -> Update Project and the errors disappeared.

Solution 3

Note that if you're using IntelliJ, you'll want to install the Lombok plugin (available from IDE settings) and also enable annotation processing.

Solution 4

Download Lombok Jar, let’s maven do the download on our behalf :

 <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.18</version>
    </dependency>

Now... mvn clean install command on the newly created project to get this jar downloaded in local repository. Goto the jar location, execute the command prompt, run the command : java -jar lombok-1.16.18.jar

enter image description here

click on the “Specify Location” button and locate the eclipse.exe path LIKE : enter image description here

finally install this by clicking the “Install/Update”

Solution 5

If you use eclipse. You must have lombok installed in your Eclipse by running lombok-xyz.jar (e.g. you can find in ~/.m2/repository/org/projectlombok/lombok/1.12.6/lombok-1.12.6.jar).

As the window of installation opened, you must choose the location of your Eclipse. And let it install lombok inside. You must restart your Eclipse afterwards.

Share:
243,939
Heetola
Author by

Heetola

when to INIT, knows python and java

Updated on January 25, 2022

Comments

  • Heetola
    Heetola over 2 years

    I just tried to send a Maven-based project to another computer and HORROR, red markers everywhere!!

    However, mvn clean install is building just fine.

    Quickly, I noticed that Lombok is not generating getters and setters for my classes, although the @Getter and @Setter are being correctly recognised by Eclipse.

    Both computers use the same Maven version (3.0.4) but different JDKs (1.6_23 and 1.6_33). They both use Eclipse Indigo 32 bit. Do you have an idea about how to solve the problem?

    • Roel Spilker
      Roel Spilker almost 12 years
      For full instructions, see stackoverflow.com/questions/3418865/… . This also incluses how to start Eclipse via a shortcut.
    • AncientSwordRage
      AncientSwordRage almost 11 years
    • logixplayer
      logixplayer over 4 years
      I did all the above steps BUT it wasn't working still. I looked at pom.xml again and commented out <!-- <optional>true</optional> --> which came by default. I later add this <!-- <scope>provided</scope> --> but commented it out as well.
    • Net Dawg
      Net Dawg over 2 years
      Why does only Lombok seem to have this problem, seems by design (to get attention)? Decorators from other annotation jars seem to just work after importing.
  • nanosoft
    nanosoft about 9 years
    If even after doing above steps it doesn't work, then EXIT and START eclipse again. Simple File->Restart doesn't work. Explicit EXIT and Start is necessary.
  • nanosoft
    nanosoft about 9 years
    "Explicitly exit and then start again. ". Normal File-->Restart doesn't work.
  • Heetola
    Heetola about 9 years
    I believe I did this while eclipse was closed
  • nanosoft
    nanosoft about 9 years
    If it was closed then fine it work with next start. But if it is already started and Explicit EXIT and start is required.
  • SMT
    SMT over 8 years
    Well done @Elidosa --- It's working, but yes need to Exit and start eclipse , only restart does't work
  • Aditya
    Aditya over 7 years
    I also needed to clean the projects to remove compilation errors
  • PAA
    PAA over 6 years
    Still I am facing the issue not sure whats wrong is going on ?
  • GoutamS
    GoutamS over 6 years
    Do you have any error message? Can you import the class in your Pojo Files?
  • GoutamS
    GoutamS over 6 years
    @Prateek In case of not working, please change lombok version.And try again
  • Vikash
    Vikash about 6 years
    thanks nanosoft!.. I was doing File>restart and it wasn't working..had tried everything
  • ArifMustafa
    ArifMustafa about 6 years
    I download the lombok.jar manually, ran it and later restarted eclipse and rebuilded projects, it's worked!...
  • MS Berends
    MS Berends over 5 years
    Welcome to StackOverflow! Please try to write your answers more readable, by using correct lists and markdown language like this.
  • Naseer Mohammad
    Naseer Mohammad over 5 years
    when I am trying to execute jar getting "Invalid or corrupt jarfile lombok-1.18.2.jar" What to do???
  • Vaibs
    Vaibs about 5 years
    Still several would have come to this thread when they were facing the same thing and not knowing if the plugin is needed for the IntelliJ. thumbs up
  • sanimalp
    sanimalp about 5 years
    If any of the above still don't work, ensure the project can be otherwise built/compiled using maven/gradle. Then, delete the project from your workspace, and re-import it, ensuring the project build invocation completes successfully with lombok references in place.
  • Vikki
    Vikki over 4 years
    Just upgrade the Lombok Plugin in Intellij Idea and restart the IDE
  • Derick Daniel
    Derick Daniel about 4 years
    This is the simplest solution i ve found till now. It worked. Thanks.
  • YazidEF
    YazidEF about 4 years
    here I am in year 2020 still finding your post useful. Thanks!
  • Rajeev
    Rajeev about 4 years
    I had same issue tried everything but didn't work. Then what I did is, I installed fresh and before doing anything I installed Lombok. It worked. Also, make sure that you start with the fresh workspace. It didn't work with the old one.
  • Ben
    Ben almost 4 years
    I followed all steps you described but with eclipse 2019-12 and lombok 1.18.12, eclipse does not recognize that there is a \@getter or \@setter annotation in my model. Is there even a getter or setter generated by lombok?
  • sofs1
    sofs1 almost 4 years
    How come this answer didn't have even a single vote. THis really helped. Thanks a ton.
  • Tiago Medici
    Tiago Medici almost 4 years
    it is duplicated answer
  • Demobilizer
    Demobilizer about 3 years
    what in case of Netbeans? Where can I find Netbeans 12.3 location on ubuntu! I tried to /snap, but not working
  • Demobilizer
    Demobilizer about 3 years
    in case of Netbeans? any idea?
  • Tejas
    Tejas over 2 years
    Try stackoverflow.com/a/69332138/3637115, it worked for me.