0

I'm having an issue with Lombok or Eclipse, not sure which. I have a Spring Boot maven project for which I am using Lombok. I've added this in my pom.xml file and I've used the lombok install for eclipse.

Whats happening is that I can do a mvn clean and a mvn install and a maven update on the project and everything builds as expected. As soon as I go to run the project errors start to appear and I get error such as:

java.lang.Error: Unresolved compilation problems: 
    The method getxxx() is undefined for the type xxxxxx

Is there anything that can happen when running the project that can some how strip out lombok?!

I'm running Eclipse Oxygen (4.7.3) with lombok v1.16.18 "Dancing Elephant" any help would be much appreciated.

SpaceCowboy
  • 543
  • 6
  • 16
  • 1
    That's because your getter and setter methods aren't generated in your `.class` files when you run the project. Please check [**this answer**](https://stackoverflow.com/a/11807022/3669624) for more details. – cнŝdk Jul 05 '18 at 14:08
  • That sounds like the issue to me, however when I follow the instructions in the answer to provided I still get the same issue :( – SpaceCowboy Jul 05 '18 at 14:20
  • What version of Java are you targeting? I've had similar issues with Java 9 and Java 10. Java 8 is the only one that seems to work perfectly. – Michael Jul 05 '18 at 14:23
  • Did you also do `mvn eclipse:eclipse` after adding lombok to the pom? Also, are you running the project from within Eclipse, or from maven/appassembler/whatever? – tobias_k Jul 05 '18 at 14:25
  • I'm using Java 8, strangely it has been working perfectly. Only recently this has started to occur. I've rolled back to a version which worked but im still seeing the issue – SpaceCowboy Jul 05 '18 at 14:26
  • @tobias_k yeah I did, I'm running it from within Eclipse – SpaceCowboy Jul 05 '18 at 14:27
  • Still not entirely clear. You say you can build the project with maven (`mvn install`), but can you also (a) run it with maven/from command line, (b) compile it in Eclipse (no squigly red lines), (c) run it in Eclipse? – tobias_k Jul 05 '18 at 14:28
  • @SpaceCowboy Try to close and start eclipse after adding lombok and executing the suggested command, if you check [this answer](https://stackoverflow.com/a/22332248/3669624) as well, it's stating the same thing. – cнŝdk Jul 05 '18 at 14:29
  • I can build with mvn clean/install in eclipse, also on the commandline, but I can't run it from anywhere as it complains about missing getters/setters – SpaceCowboy Jul 05 '18 at 14:32

3 Answers3

0

I don't know how exactly in eclipse, but in the ​​Intellij IDEA I need to install the lombok plugin in the settings, I suspect that in eclipse also it needs to be done.

Andrii Torzhkov
  • 271
  • 1
  • 5
  • 15
0

Here is tested link for setting up lombok for the eclipse as well as intellij.

https://www.baeldung.com/lombok-ide

Rishabh Agarwal
  • 2,374
  • 1
  • 21
  • 27
0

Adding the tag <annotationProcessorPaths> to pom.xml solved my same problem.

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>RELEASE</version>
                    </path>
                </annotationProcessorPaths>
                ...
            </configuration>
        </plugin>
    </plugins>
</build>
TJBlackman
  • 1,895
  • 3
  • 20
  • 46