문제

I have followed the tutorial here http://projectlombok.org/

but after adding import and @Data nothing happens.

Does it work on eclipse helios ?

도움이 되었습니까?

해결책

Did you add

-vmargs
...
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar

to your eclipse.ini?

Because if you have (and if you have added the lombok.jar to the libraries used by your project), it works just fine with Eclipse Helios:

alt text


Ian Tegebo mentions in the comments that:

a simple "restart" was not sufficient to pick up the changed vmargs:
I needed to explicitly exit and then start again.


chrisjleu mentions in the comments:

If you happen to be running a customized Eclipse Helios (3.6+) distribution then you may have to use the full path to lombok.jar in both the vm arguments.
See commit b47e87f for more details.

boolean fullPathRequired = IdeFinder.getOS() == EclipseFinder.OS.UNIX || System.getProperty("lombok.installer.fullpath") != null;

다른 팁

You not only have to add lombok.jar to the libraries, but also install it by either double-clicking the lombok jar, or from the command line run java -jar lombok.jar. That will show you a nice installer screen. Select your Eclipse installation and install.

Afterwards, you can check if the installer has correctly modified your eclipse.ini:

-vmargs
...
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar

If your Eclipse was already running, you have to Exit Eclipse and start it again. (File/Restart is not enough)

If you are starting Eclipse using a shortcut, make sure that either there are no command line arguments filled in, or manually add -javaagent:lombok.jar -Xbootclasspath/a:lombok.jar somewhere after -vmargs.

Recent editions of Lombok also add a line to the About Eclipse screen. If Lombok is active you can find a line like 'Lombok v0.11.6 "Dashing Kakapo" is installed. http://projectlombok.org/' just above the line of buttons.

If for some reason, usually related to customized eclipse builds, you need to use the full path, you can instruct the installer on the command line to do so:

java -Dlombok.installer.fullpath -jar lombok.jar

After adding lombok and restarting eclipse or spring tools my project still failed to recognize getters and setters. Red markers everywhere!

The solution: right-click your project, go to Maven and select Update Project

After hours of searching and trying random solution, I find this to be the only solution that worked for me.

enter image description here

Please follow the following steps:- If lombok jar has already been added as dependency in eclipse, then go to project's lib folder > Locate Lombok.xx.jar > Right Click on Jar> Run as Java Application> This will launch Lombok screen as below:- enter image description here

Next, click on "Specify location" > And specify location of "Eclipse.ini" file.(Eclipse neon on Mac osX has it at -> "<Eclipse_installation_path>/jee-neon/Eclipse.app/Contents/Eclipse/Eclipse.ini").

After this, restart eclipse and Clean build project.

This worked for me.

I can only make this work if I start the eclipse.exe directly in the eclipse installation folder. If I use a command file setting some initial JAVA_HOME and maven parameters before running the eclipse.exe it does not work and I get compiler errors on the exact same projects

Don't forget to do to Project->Clean in eclipse to make sure that your classes are recompiled.

Remenber run lombok.jar as a java app, if your using windows7 open a console(cmd.exe) as adminstrator, and run C:"your java instalation"\ java -jar "lombok directory"\lombok.jar and then lombok ask for yours ides ubication.

I ran into this problem due to the missing:

-vmargs -javaagent:lombok.jar -Xbootclasspath/a:lombok.jar

as well. What is not explicitly said neither here nor in the Lombok popup message, and was not obvious to me as someone who never before had to fiddle with the eclipse.ini, is that you are NOT supposed to add that line, but instead add the last two parts of that line after the first part, which is already in the eclipse.ini file. To better illustrate, the end of the file should look something like this (bold is what matters for Lombok, the rest might be different for you):

-vm
C:/Program Files/Java/jdk1.7.0_02/bin
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx384m
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar

This sometimes does not work if Eclipse is on one of those strange default windows paths (e.g. c:/Program files (86)/Eclipse).

In that case, do as above, then move the lombok jar to a cleaner path without spaces and braces (e.g. c:\lombok\lombok.jar) and modify eclipse.ini accordingly.

If you are using windows xp and eclipse juno then it should be like this in order

-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar
-Xms40m
-Xmx512m

I could not install lombok.jar on my MacBook Pro because of the version of Java. I had to downgrade to Java 1.6 to install and then I reused Java 1.7 when the installation worked !

You can see the different JVM installed on your machine here : /System/Library/Java/JavaVirtualMachines

  1. Copy the Lombok jar into your eclipse based IDE (Eclipse/STS etc-) install folder

    • note that the install folder is the folder that has the .ini file for your IDE
    • if you use Maven to pull in the jar, then get it from your m2 repository
    • cp ~/.m2/repository/projectlombork/lombork-1.x.jar /path/to/IDE/lombok.jar
  2. Edit the .ini file in the install folder of your IDE and add the following lines below -vmargs.

    • -javaagent:lombok.jar -Xbootclasspath/a:lombok.jar
    • note that the jar should be in the same folder as the .ini file and the name of the jar lombok.jar
  3. Restart your IDE and rebuild/maven-update your project

I had similar issue on MacBook Pro, I just followed the below link and issue got resolved. https://projectlombok.org/setup/eclipse

Steps followed:-

  • Download the lombok.jar
  • Double click on this jar
  • This jar will try to find the eclipse installed on the machine, but in my case it was not able to identify the eclipse though I installed on it, this could be due to softlink to the eclipse path.
  • I just specified the location of the eclipse ini file by clicking "Specify location" button
  • This jar automatically updated the entry in eclipse.ini file for javaagent
    • I added the same jar to the classpath of the project in the eclipse
    • Restarted my eclipse

I searched for lomob.jar in .m2 repo. Once you double click it -> Search eclipse.exe and select it. After lombok will make the required changes. Explicitly quit eclipse -> it should be fixed by now. If not do a maven Update.

I am on Eclipse Neon, and after following the above steps, it still didnt work. import lombok.Data; was not being recognized.

After about an hour of looking around, i switched the version to 1.16.14 and it worked.

Now my thought is, whether the 1 hour spent will be a good investment for long term :-)

Eclipse Oxygen - after installation of Lombok according to the process described on the Lombok page, still could not use @Log annotation.

Solution : Project --> Properties - Enable annotation processing

Just faced this issue (compiler errors for generated getters) and none of the proposed solutions helped.

Setup: Eclipse Oxygen (32bit), SAP_JVM (32bit), Lombok 1.16.18 (Eclipse plugin properly installed).

Created a plain new test project, which worked like a charm. Afterwards deleted the failing project and checked it out again from my Github repo, which fixed the errors. Just deleting the project from the workspace and importing it again, didn't help.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top