7

I have a problem with my project. It is an Spring CRUD RestFul API that expose services witch are providing Json datas. I use JDK-7, Eclipse-Neon and Maven to code, build and the project is deployed into a JBossEAP 6.4 server. Every thing is working well, the services are responding correctly.

So I decide to add Lombok, to reduce the boiler code and improve the readability of the code. By the way I used Lombok on an another project before and is worked fine.

Here is my problem, after including Lombok : - When I make an ear using Maven (mvn clean install), everything is going well, the project deploy and work perfectly fine. - When the project is built by Eclipse, the Lombok annotations (i.e.:@Data, etc) aren't included into the *.class. Consequently the ear deployed by Eclipse work fine BUT all the entity haven't any getter / setter and so on.

I know Eclipse is correctly configured because I haven't any warning associated to Lombok on my code, the outline view of eclipse show me generated methods.

Does anyone have a idea about this kind of problem?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Zorglube
  • 664
  • 1
  • 7
  • 15
  • Have you added the lombok dependency to your POM? – Mark Rotteveel Feb 17 '17 at 15:16
  • Yes I do. I have no problem with the maven build, I have problem with the Eclipse build. ` org.projectlombok lombok 1.16.10 provided ` – Zorglube Feb 17 '17 at 15:19
  • Try to update the Maven configuration. Right click on the project choose "Maven" and then "Update Project Configuration" – Simon Martinelli Feb 17 '17 at 15:20
  • Ah, sorry, somehow I read it exactly the other way around,. – Mark Rotteveel Feb 17 '17 at 15:20
  • @simas_ch, also did it many times. – Zorglube Feb 17 '17 at 15:22
  • @Mark, no problem, thank by the way. – Zorglube Feb 17 '17 at 15:22
  • Usually, Eclipse comes embedded with a built in maven. As you are saying that when you build using command prompt everything works well, why not try adding your maven installation to eclipse and force eclipse to use the maven that you installed on your machine instead of its own embedded maven. You can do this on Eclipse by `Windows - > Maven - > Installations`. Here, provide your maven installation details. Also, make sure that the `Windows -> Maven -> User Settings` are correctly configured to point to your maven installation settings.xml file. – RITZ XAVI Feb 17 '17 at 21:10
  • @Ritz thank for the idea. I didn't told that into my decription, but, eclipse is already configured to use my own Maven installation so not the embeded one. – Zorglube Feb 20 '17 at 10:23
  • I am having the same issue – Sacky San Feb 18 '18 at 10:32
  • @JanRieke I'm not sure, my problem seems to be an Lombok or an Eclipse error in the code ; the duplication you purpose seems to be an installation mistake. – Zorglube Sep 07 '18 at 08:41
  • I think you either have not installed the current Lombok plugin version in your Eclipse, or the Lombok plugin is not installed at all. Try reinstalling the Lombok Eclipse plugin. This is what is described in the linked question/answer. – Jan Rieke Sep 07 '18 at 08:48
  • Despite the fact that my question is very old and i don't have the problem yet, my problem wasn't the Lombok installation. – Zorglube Sep 07 '18 at 08:50
  • I know, just checking some old unanswered stuff in case someone has a similar problem. :) – Jan Rieke Sep 07 '18 at 08:54
  • Try https://stackoverflow.com/a/69332138/3637115 , it worked for me. – Tejas Sep 26 '21 at 06:00

1 Answers1

4

You also must have the lombok plugin installed in Eclipse. (Note that this is something different from lombok being present in the project dependencies; you need both.) Furthermore, the version installed in Eclipse should be the same version that you have in your pom.xml. Otherwise strange compilation issues may occur, like code for some annotations not getting generated in Eclipse but in maven, or vice versa.

Installation instructions for Eclipse can be found here.

Check the "About Eclipse" dialog after the installation and an Eclipse restart. It must contain some text like "Lombok v1.18.3 "Edgy Guinea Pig" is installed.". If that is not the case, the lombok plugin is not installed correctly.

If the installation was not successful, you should try installing lombok to a clean Eclipse installation (even before adding any projects).

Explanation: Eclipse uses its own compiler (different from javac, which maven uses). Therefore, lombok also has to hook into the Eclipse compilation process, and therefore, Eclipse needs that lombok plugin.

Also note that Lombok annotation should never be present in the compiled class file, because the Lombok annotation processor removes them when generating the replacement code.

Jan Rieke
  • 7,027
  • 2
  • 20
  • 30