Lombok @Builder "cannot find symbol" error with Maven & IntelliJ

Hey everyone, I'm facing a frustrating issue with Project Lombok and could use some help. I'm working on a Spring Boot project using IntelliJ IDEA and Maven, and I'm getting a java: cannot find symbol error for the builder() method. The error occurs in my test class ShutterResponseDTOTest.java when I try to instantiate a DTO using the builder pattern. Here are the relevant code snippets and the full error message. What I've already checked and done: I've correctly added the Lombok dependency to my pom.xml. I’ve confirmed that “Enable annotation processing” is checked in my IntelliJ IDEA settings (Settings > Build, Execution, Deployment > Compiler > Annotation Processors). I also tried using the <optional>true tag for the dependency, but that didn't work either, so I reverted to provided. I have the Lombok plugin installed in IntelliJ.
No description
No description
No description
No description
No description
13 Replies
JavaBot
JavaBot7d ago
This post has been reserved for your question.
Hey @kyrylomalyi! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Madjosz
Madjosz7d ago
Have you tried explictly rebuilding your project? Also <optional>true</optional> is something which is relevant when resolving transitive dependencies. I think what you are looking for is <scope>compile</scope> but this is already the default.
kyrylomalyi
kyrylomalyiOP7d ago
yeah rebuilding using idea button and than also ./mvnw test
kyrylomalyi
kyrylomalyiOP7d ago
and again getting same error
No description
No description
Madjosz
Madjosz7d ago
Do you have the annotation processor set up in the configuration of your <build> plugins in the pom.xml?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
kyrylomalyi
kyrylomalyiOP7d ago
yes i have it was auto generated by spring intlzr
No description
kyrylomalyi
kyrylomalyiOP7d ago
also tried to check would it works in just main class not in test enviroment and it also does not work here
No description
Madjosz
Madjosz7d ago
Does it build from command line?
kyrylomalyi
kyrylomalyiOP7d ago
test or main with builder?
Madjosz
Madjosz7d ago
The one which is not working.
kyrylomalyi
kyrylomalyiOP7d ago
OKAY look ive tried ./mvnw clean install and now everything works great thank you! u are smarter than ai
JavaBot
JavaBot7d ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot7d ago
Post Closed
This post has been closed by <@1406725416932216894>.

Did you find this page helpful?