java: cannot find symbol symbol: method builder()

before you ask, I've already enabled annotation processing in my spring boot project. I don't really know what else I can do
103 Replies
JavaBot
JavaBotā€¢3w ago
āŒ› This post has been reserved for your question.
Hey @IamMax420! 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.
dan1st
dan1stā€¢3w ago
Are you using JDK 23? Are you using a version of Lombok that's less than 1.18.36? If the answer to both of these is yes, you need to update Lombok
dan1st
dan1stā€¢3w ago
Stack Overflow
Build Failure: @Data Annotation won't regonize by Maven
I consider that my maven has problems with the annotation @Data from lombok. About the project: Java 23 Spring Boot Version 3.3.4 also using Intellij ultimate The error appears after like mvn comp...
IamMax420
IamMax420OPā€¢3w ago
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.36</version> <scope>provided</scope> </dependency> still getting the same error...
dan1st
dan1stā€¢3w ago
you probably need to add <proc>full</proc> to the maven-compiler-plugin
IamMax420
IamMax420OPā€¢3w ago
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </path> </annotationProcessorPaths> <proc>full</proc> </configuration> </plugin> Idk if this is right but I'm still getting the error
ayylmao123xdd
ayylmao123xddā€¢3w ago
can you show the method at which ur getting the error šŸ˜±
dan1st
dan1stā€¢3w ago
Can you show your full pom.xml?
ayylmao123xdd
ayylmao123xddā€¢3w ago
maybe its just wrong syntax
dan1st
dan1stā€¢3w ago
The error is lombok not running lombok is known for that
ayylmao123xdd
ayylmao123xddā€¢3w ago
might be also cuz lombok is not updated
IamMax420
IamMax420OPā€¢3w ago
Phloof_boll
Phloof_bollā€¢3w ago
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.36</version> <scope>provided</scope> </dependency> still getting the same error...
ayylmao123xdd
ayylmao123xddā€¢3w ago
happens to me all the time when updating plugins
dan1st
dan1stā€¢3w ago
Can you show the output of mvn help:effective-pom?
IamMax420
IamMax420OPā€¢3w ago
yeah
dan1st
dan1stā€¢3w ago
it normally happens when updating the JDK, not when updating plugins try explicitly setting the version of the maven-compiler-plugin to 3.13.0
ayylmao123xdd
ayylmao123xddā€¢3w ago
i mean if lombok wasnt recognizing the annotation at all it should be underlined
dan1st
dan1stā€¢3w ago
no that would be if javac didn't recognize the annotation the error is lombok not correctly processing it
ayylmao123xdd
ayylmao123xddā€¢3w ago
or syntax error at the calling method
dan1st
dan1stā€¢3w ago
which happens all the time with lombok cause it uses unsupported operations
ayylmao123xdd
ayylmao123xddā€¢3w ago
cuz we havent seen the actual code yet
IamMax420
IamMax420OPā€¢3w ago
did that, still getting the error..
dan1st
dan1stā€¢3w ago
Can I see that?
IamMax420
IamMax420OPā€¢3w ago
private UserDto mapToUserDto(User user) { return UserDto.builder() .id(user.getId()) .firstName(user.getFirstName()) .secondName(user.getSecondName()) .email(user.getEmail()) .createdAt(user.getCreatedAt()) .updatedAt(user.getUpdatedAt()) .build(); } this is the method
ayylmao123xdd
ayylmao123xddā€¢3w ago
oops wrong gif
IamMax420
IamMax420OPā€¢3w ago
umm what directory do I run that command in
dan1st
dan1stā€¢3w ago
the project directory
ayylmao123xdd
ayylmao123xddā€¢3w ago
or in maven console did you make sure to add the builder annotation to userdto btw
IamMax420
IamMax420OPā€¢3w ago
yes
ayylmao123xdd
ayylmao123xddā€¢3w ago
or superbuilder
IamMax420
IamMax420OPā€¢3w ago
bro I'm too slow I go to the project directory and I can't run that
dan1st
dan1stā€¢3w ago
What happens when running it?
IamMax420
IamMax420OPā€¢3w ago
mvnw.cmd : The term 'mvnw.cmd' is not recognized as the name of a cmdlet, function, script file, or operable program. C heck the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + mvnw.cmd help:effective-pom + ~~~~ + CategoryInfo : ObjectNotFound: (mvnw.cmd:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Suggestion [3,General]: The command mvnw.cmd was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\mvnw.cmd". See "get-help about_Command_Precedence" for more details.
dan1st
dan1stā€¢3w ago
which IDE are you using?
ayylmao123xdd
ayylmao123xddā€¢3w ago
are you using intellij
IamMax420
IamMax420OPā€¢3w ago
yes intellij idea community edition
dan1st
dan1stā€¢3w ago
Press Ctrl twice and then enter mvn help:effective-pom in the dialog that pops up
ayylmao123xdd
ayylmao123xddā€¢3w ago
yea try that
dan1st
dan1stā€¢3w ago
I hope they haven't changed that keybind in the last few years
IamMax420
IamMax420OPā€¢3w ago
ooooh ok I got some logs
dan1st
dan1stā€¢3w ago
Can you show it? Specifically the XML Is there a lombok dependency in it? I think you can use ctrl+F to search for it
IamMax420
IamMax420OPā€¢3w ago
I'm looking for it yeah
IamMax420
IamMax420OPā€¢3w ago
<lombok.version>1.18.36</lombok.version>
dan1st
dan1stā€¢3w ago
meanwhile having "lmao" in the name - lmao sry I had to make that joke
ayylmao123xdd
ayylmao123xddā€¢3w ago
no problem
IamMax420
IamMax420OPā€¢3w ago
nahh man fuck this, I'm still getting this error It's 11 pm in Poland and I have yet to work out
ayylmao123xdd
ayylmao123xddā€¢3w ago
here its a mental workout
IamMax420
IamMax420OPā€¢3w ago
thanks for your guys' help I'll get some sleep, wake up, look at it at probably spot the solution
JavaBot
JavaBotā€¢3w 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.
IamMax420
IamMax420OPā€¢3w ago
justas usual
dan1st
dan1stā€¢3w ago
Can you show the actual <dependency> as well as the maven-compiler-plugin in the <plugins> section of the effective POM? I'm in Austria so it's the same time for me ;)
ayylmao123xdd
ayylmao123xddā€¢3w ago
i was in roblox austria once we were shooting guns
IamMax420
IamMax420OPā€¢3w ago
<plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.13.0</version> <executions> <execution> <id>default-compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> <configuration> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.36</version> <scope>provided</scope> </path> </annotationProcessorPaths> <proc>full</proc> <parameters>true</parameters> </configuration> </execution> <execution> <id>default-testCompile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> <configuration> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.36</version> <scope>provided</scope> </path> </annotationProcessorPaths> <proc>full</proc> <parameters>true</parameters> </configuration> </execution> </executions> <configuration> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.36</version> <scope>provided</scope> </path> </annotationProcessorPaths> <proc>full</proc> <parameters>true</parameters> </configuration> </plugin> this?
dan1st
dan1stā€¢3w ago
Actually there are other things you could try: - Compile it via mvn clean verify and check for the same error - Check whether there is a plugin named "Lombok" installed in IntelliJ (it should be there by default but better to be safe) - If that plugin has an update, update it - Update IntelliJ yes, exactly this and it looks fine
ayylmao123xdd
ayylmao123xddā€¢3w ago
ha i will be so right
dan1st
dan1stā€¢3w ago
feel free to check these tomorrow
ayylmao123xdd
ayylmao123xddā€¢3w ago
if it wont work because of the lombok update
IamMax420
IamMax420OPā€¢3w ago
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project Kanban: Unable to parse configuration of mojo org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile for parameter scope: Cannot find 'scope' in class org.apache.maven.plugin.compiler.DependencyCoordinate -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
dan1st
dan1stā€¢3w ago
ohhhh remove the scope>provided</scope> in the <annotationProcessorPaths> then update the Maven project in IntelliJ maybe IntelliJ calls it "reloading"
IamMax420
IamMax420OPā€¢3w ago
how?
dan1st
dan1stā€¢3w ago
Is there a reloading symbol (with an "m") in the editor? Is there a "Maven" tab on the right? If yes, click it
ayylmao123xdd
ayylmao123xddā€¢3w ago
yea and the first icon in the list is to refresh
dan1st
dan1stā€¢3w ago
If yes, open it. There should be a reload symbol on the top left of that tab. Click it.
ayylmao123xdd
ayylmao123xddā€¢3w ago
mvn clean install could work too ig
dan1st
dan1stā€¢3w ago
Also you could try running mvn clean verify again (via double-ctrl again) No, don't mvn install install bad in most cases listen to Maven devs
IamMax420
IamMax420OPā€¢3w ago
yeah so I clicked the reload icon and ran that command, still getting the aforementioned error
dan1st
dan1stā€¢3w ago
install adds it to the local repo
ayylmao123xdd
ayylmao123xddā€¢3w ago
interesting
dan1st
dan1stā€¢3w ago
the compiler error about builder() not existing? Can you try mvn clean verify again? And show your current pom.xml again as well?
IamMax420
IamMax420OPā€¢3w ago
oh shit it doesn't exist
ayylmao123xdd
ayylmao123xddā€¢3w ago
maybe it for real is a wrong version of lombok
IamMax420
IamMax420OPā€¢3w ago
I mean the builder() error is no moroe
dan1st
dan1stā€¢3w ago
what exactly? ah ok nice
dan1st
dan1stā€¢3w ago
ig it works now?
IamMax420
IamMax420OPā€¢3w ago
but I'm still getting this not sure if this is big of an issue btw thanks a lot guys
JavaBot
JavaBotā€¢3w 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.
dan1st
dan1stā€¢3w ago
After removing the <scope>? yes, it is
IamMax420
IamMax420OPā€¢3w ago
yeah
dan1st
dan1stā€¢3w ago
it means your pom.xml is invalid Are you getting that exact error? Can you show your full pom.xml?
ayylmao123xdd
ayylmao123xddā€¢3w ago
100 bucks that its lombok version being incompatible
IamMax420
IamMax420OPā€¢3w ago
ayylmao123xdd
ayylmao123xddā€¢3w ago
in the plugins tab in project settings there should be an option to update it
IamMax420
IamMax420OPā€¢3w ago
I deleted the <scope> tag from here: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
ayylmao123xdd
ayylmao123xddā€¢3w ago
try to see if its there
dan1st
dan1stā€¢3w ago
you still have the <scope>provided</scope>
ayylmao123xdd
ayylmao123xddā€¢3w ago
settings plugins
IamMax420
IamMax420OPā€¢3w ago
huh
dan1st
dan1stā€¢3w ago
I was talking about the <annotationProcessorPaths> in the maven-compiler-plugin
IamMax420
IamMax420OPā€¢3w ago
ah my bad
dan1st
dan1stā€¢3w ago
The <scope>provided</scope> was fine in the <dependency>
IamMax420
IamMax420OPā€¢3w ago
either way it works now no errors yaayy lol
ayylmao123xdd
ayylmao123xddā€¢3w ago
šŸ˜± o ma gawd
dan1st
dan1stā€¢3w ago
it wasn't a compatibility issue ;)
ayylmao123xdd
ayylmao123xddā€¢3w ago
šŸ¤“ next time it will be time to donate the 100 bucks i lost
dan1st
dan1stā€¢3w ago
next time you can link to my answer if it's still about JDK 23: https://stackoverflow.com/a/79210588/10871900
ayylmao123xdd
ayylmao123xddā€¢3w ago
will do
JavaBot
JavaBotā€¢2w ago
šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server