Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build cannot find symbol when accessing project lombok annotated methods,

Tags:

java

maven

lombok

I'm using project lombok for the first time and I have problems compiling the project via maven when I run the build I receive errors where methods annotated with project lombok annotations are called.

This is the annotated parameter:

    private @Getter @Setter String paymentNonce = null; 

and in this line for example the maven breaks the build:

if (!StringUtilities.isNullOrEmpty(getPaymentNonce())) { 

this is my maven dependency

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

the maven error:

[INFO] Compiling 158 source files to C:\java\repos\luna\cloudflow\cloudflow-ejb\target\classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] \java\repos\luna\cloudflow\cloudflow-ejb\src\main\java\si\arctur\controller\PaymentProcessor.java:[94,38] error: cannot find symbol [ERROR] \java\repos\luna\cloudflow\cloudflow-ejb\src\main\java\si\arctur\controller\PaymentProcessor.java:[97,106] error: cannot find symbol [ERROR] \java\repos\luna\cloudflow\cloudflow-ejb\src\main\java\si\arctur\controller\PaymentProcessor.java:[142,2] error: cannot find symbol [ERROR] \java\repos\luna\cloudflow\cloudflow-ejb\src\main\java\si\arctur\controller\ShoppingCart.java:[27,6] error: cannot find symbol [ERROR] \java\repos\luna\cloudflow\cloudflow-ejb\src\main\java\si\arctur\controller\ShoppingCart.java:[32,75] error: cannot find symbol ..... 

I'm using java 8

like image 608
simonC Avatar asked Dec 18 '15 15:12

simonC


2 Answers

Had the same problem using maven-compiler-plugin v.2.3.2 After updating the version up to 3.5 problem disappeared

<plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-compiler-plugin</artifactId>     <version>3.5</version>     <configuration>         ...     </configuration> </plugin> 

Hope this helps

like image 131
Andrew Onischenko Avatar answered Sep 18 '22 18:09

Andrew Onischenko


I was actually able to solve this by following an answer posted here :

MapStruct and Lombok not working together

Basically I had to add lombok to the maven-compiler-plugin <annotationProcessorPaths>

like image 40
Fabian Avatar answered Sep 16 '22 18:09

Fabian