Lombok problems with Eclipse Oxygen

喜夏-厌秋 提交于 2019-12-17 18:02:02

问题


I upgraded recently to the new Eclipse version (Oxygen). I downloaded the lombok.jar from the website and installed it. This is how the eclipse.ini looks like after installation:

-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
C:\Users\xxx\.p2\pool\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.500.v20170531-1133
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
-javaagent:lombok.jar

I can use Lombok as seen here:

But when using the getters/setters and/or constructors in other classes I get the this errors:

Also these are my Eclipse and Lombok versions:

Eclipse Java EE IDE for Web Developers.
Version: Oxygen Release (4.7.0)
Build id: 20170620-1800
Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/

Anyone knows how I can fix it?


回答1:


My env: java version "1.8.0_144"

Eclipse: Eclipse Java EE IDE for Web Developers. Version: Oxygen Release (4.7.0) Build id: 20170620-1800

  1. Exit Eclipse(if it is open) and downloaded jar from https://projectlombok.org/download

  2. execute command: java -jar lombok.jar

  3. This command will open window as shown here https://projectlombok.org/setup/eclipse, install and quit the installer.

  4. Add jar to build path/add it to pom.xml.

    e.g. for Gradle build

 annotationProcessor("org.projectlombok:lombok")
 compileOnly("org.projectlombok:lombok")
  1. restart eclipse.
  2. Go to Eclipse --> About Eclipse --> check 'Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/'
  3. To enable Lombok for the project: Enable annotation processing in the respective IDE. That's it. It worked. I did not change eclipse init script.

Note: Read the note in following image regarding -vm options If you start Eclipse with a custom -vm parameter, you'll need to add:

-vmargs -javaagent:<path-to-lombok-jar>/lombok.jar

as parameter as well

Above steps works for Photon Release (4.8.0) - Lombok v1.18.2, eclipse: Oxygen.3a Release (4.7.3a) - Lombok v1.18.0 and eclipse: Neon.3 Release (4.6.3) - Lombok v1.18.2

lombok success screen:

fyi,
For JDK - 10 and 11 support: Lombok version should be at least v1.18.4 (October 30th, 2018) or higher.




回答2:


For MacBook Pro users (e.g. running macOs Sierra v10.12.6), in order to install lombok on Eclipse Oxygen (4.7.0) or Photon (4.8.0), using Java 1.8 (1.8.0_144), just do the following actions:

  1. Download lombok from the site Project Lombok;
  2. Close your Eclipse IDE if it is open;
  3. Trigger lombok installation either by following the official installation steps or by executing the command: java -jar lombok.jar;
  4. If the lombok installer doesn't find your Eclipse IDE, you will be requested to enter the path to your Eclipse. You should input the path to your eclipse.ini file. In my case was /tools/ide/eclipse/jee-oxygen/Eclipse.app/Contents/Eclipse/eclipse.ini.
  5. Quit the installer and open Eclipse.
  6. On the menu bar, go to Eclipse > About Eclipse and validate that lombok is installed:

    Lombok v1.16.18 "Dancing Elephant" is installed. https://projectlombok.org/
    

    Be sure to scroll the text window down since the installed Lombok version appears in the text above the row of icons.

  7. Finally, add lombok to your project's build path according to the building tool you're using. For Maven, for instance, use the following dependency:

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



回答3:


Had problems with Eclipse Oxygen, Java 1.9 and Lombok (on Mac OSX - windows/linux should be similar).

This is what I had to do:

  1. Download the latest lombok: 1.16.20
  2. Open up eclipse, and check for updates and install all of them. Ensure that eclipse is updated to the latest.
  3. Exit eclipse.
  4. java -jar lombok.jar
  5. Ensure that the location to Eclipse is correct in the installer window that pops up, I had to explicitly specify:/[some-folder-heirarchy]/Eclipse.app/Contents/Eclipse/eclipse.ini

Thereafter check to see if the updates have made it in eclipse.ini:

-javaagent:/[some_folder-hierarchy]/eclipse-oxygen/Eclipse.app/Contents/Eclipse/lombok.jar

There is only one line that is updated. That is a change from some of the earlier versions of lombok where a bootclasspath was also specified and / or the path to lombok.jar was relative. Now it is an absolute path.

Bring up eclipse and you would see Lombok in action.

And do not forget to use the same Lombok version in your maven or any other dependency management tool.

Edit 1: I also used a different version of Lombok in the maven POM from the one that is installed in eclipse and for the most part, things compiled but there were a few compile errors in eclipse. Of course, things compiled successfully on the command line with maven. So if you have project dependencies that force you to use different Lombok versions then be aware of such an eventuality. The crux is to have the same version installed in both eclipse and in your project's dependency management (maven etc.).




回答4:


Do not use old versions of java.

What happens is that lombok puts the following line in your eclipse.ini:

-javaagent: lombok.jar

And lombok.jar is in the C:\eclipse\jee-oxygen\eclipse directory

The problem is that the shortcut created by the windows installation looks like this:

Fill in the "Start at" path and it will work:




回答5:


For Linux/Ubuntu users who are launching Eclipse from a launcher (a .desktop file) that is locked to your launcher, and your Help --> About dialog doesn't show lombok is installed:

  1. Close Eclipse
  2. Unlock Eclipse from your launcher
  3. Start Eclipse from the .desktop application
  4. Verify "Help --> About" indicates lombok is installed (scroll down)
  5. Lock to your launcher again

It seems this works due to some issue with applications 'lock to launcher', and it's the unlock/lock process that fixes it.

(Thanks to cardamon's comment here that pointed me to this solution)




回答6:


I had exactly the same problem with Alex. My eclipse version is

Version: Oxygen.1a Release (4.7.1a) Build id: 20171005-1200

I installed lombok 1.16.18, after checking it was already installed and also javaagent line was added to my eclipse.ini file.

Every thing was fine except that there are compilation errors where getter is called in the project. It's awkward but I fixed by :

  1. Cleaning project

  2. Building project

  3. Restarting eclipse a few times

Nothing else.




回答7:


Solution:

  1. Install lombok 1.16.18 as instructed by lombok website. It's better Eclipse is close during installation.

  2. Make sure Eclipse can start up properly. On the shortcut, change the properties, and fill in the "Start in" path and it will work as noted by Thomas and Fabiano.

  3. Once Eclipse opens, update Maven on the project to solve compilation errors.

  4. Now Lombok latest release works with Eclipse latest release.

For reference:

My Eclipse: Oxygen

Version: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600 

My JRE/JDK: 1.8

java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

lombok 1.16.18




回答8:


Lombok does not work for Eclipse Neon

 - You should not just "restart" Eclipse, go to File -> Exit and then
   open it again.
 - Don't forget to do a mvn clean just to make sure that you recompiled your classes. 
 - After all this you should also right-click on your project, then Maven -> Update Project



回答9:


I had the same problem, however, the original development was done with lombok 1.16.10 and I had installed 1.16.18. When I downloaded and installed 1.16.10 everything worked. I probably needed to do a few cleans and rebuilds to get it to work with .18, but if you're in a hurry, try that.




回答10:


Had similiar issue but really don't remember what helped me. Of course u can try restart Eclipse. Make sure you mentioned correct Eclipse path in lombok installation. That's the topic you can find other potential solutions: Cannot make Project Lombok work on Eclipse (Helios)




回答11:


Also had problems with lombok in eclipse oxygen.

My solution: returned from java version 8u144 to 8u141.

And I refer to lombok by adding this to my eclipse.ini:

-Xbootclasspath/c:/DEV/Tools/lombok-1.16.18/lombok.jar

-javaagent:/DEV/Tools/lombok-1.16.18/lombok.jar




回答12:


If restarting Eclipse doesn't help. You have to quit the application and make sure to kill all running java processes. That worked for me.

(Eclipse Oxygen 4.7.1a, OpenJDK 1.8.0_151-b12)




回答13:


Quite a few solutions, none solved my problem.

Eclipse Oxygen 3a April 2018 the installer works fine,

My issue was running eclipse on a DCEVM JRE. Pointing Eclipse to a non-modified JVM resolved this problem.




回答14:


You can install lombok through command line very easily, ~/softwares/Eclipse.app/ path to your eclipse or sts app (this is on mac) but it will also work for different OS, and it will give you the successful output.

java -jar lombok.jar install ~/softwares/Eclipse.app/

Output:

Lombok installed to: /Users/temp/softwares/Eclipse.app



回答15:


I am using STS. After performing installation of lombok.jar shown above, need to perform following task. STS -> Project -> Properties -> Java Compiler -> Annotation Processing -> Enable Annotation Processing. See here




回答16:


I tried all this but it didn't work for me. Lombok libraries were still not adding into my classpath.

I was using the latest spring-boot version

2.1.9.RELEASE

when I reduced this to following version which worked for me

2.1.7.RELEASE




回答17:


Hello I solved that problem simply editing the lombok dependency in the pom.xml

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.16</version>
    <scope>provided</scope>
</dependency>

This version seems to work whit java 8.



来源:https://stackoverflow.com/questions/45461777/lombok-problems-with-eclipse-oxygen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!