I am working on a Spring Boot project using Lombok to generate boilerplate code such as getters, setters, and constructors. Despite having the correct Lombok dependency in the pom.xml, methods like getName() and setName() are not recognized during compilation. My IDE does not show any errors for missing Lombok-generated methods, but the project fails to compile, stating errors like:
java: cannot find symbol
symbol: method setName(java.lang.String)
location: variable test of type com.abhishek.springboot.testlombok
NOTE : It's an experiment project to test on but the lombok annotation isn't working here too.My testlombok class with visible build error below.
I expected Lombok to process annotations like @Data or @Getter/@Setter and generate the corresponding methods seamlessly during compilation. To resolve the issue, I tried the following:
I have tried almost every method available on the internet to resolve the issue with Lombok not working.
Finally, I found a very weird workaround and it worked for me. But the principle is unclear, it could be a problem with IDEA or SpringBoot or Maven, I don't know how it happened, but after doing this my lombok works.
IntelliJ IDEA Ultimate 2024.3 (243.21565.193)
Spring Boot 3.4.0
Maven Bundle 3.9.9
If you use the default Spring Boot-generated POM file, you can see build -> plugins -> :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
The version of Lombok for Spring Boot 3.4.0 is 1.18.36, add <version>1.18.36</version> here:
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
</path>
</annotationProcessorPaths>
Then sync/reolad maven project and execute mnv clean install.
It works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With