Lombok @Builder error

I'm getting this error:
java: cannot find symbol
symbol: method builder()
java: cannot find symbol
symbol: method builder()
when using the .builder() method on an object that I previously marked with the
@Builder
@Builder
annotation
60 Replies
JavaBot
JavaBot2w 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.
ayylmao123xdd
ayylmao123xdd2w ago
😱 thats truly a disaster show the code where ur trying to use builder
IamMax420
IamMax420OP2w ago
Ikr I'm going insane atp there's always some fucking bug everyday 😿 so here's where I'm using it
private Book mapToBook(BookDto bookDto) {
if(!BookServiceUtils.isBookDtoValid(bookDto)) {
return null;
}

return Book.builder()
.author(bookDto.getAuthor())
.title(bookDto.getTitle())
.category(bookDto.getCategory())
.pages(bookDto.getPages())
.quantity(bookDto.getQuantity())
.build();
}
private Book mapToBook(BookDto bookDto) {
if(!BookServiceUtils.isBookDtoValid(bookDto)) {
return null;
}

return Book.builder()
.author(bookDto.getAuthor())
.title(bookDto.getTitle())
.category(bookDto.getCategory())
.pages(bookDto.getPages())
.quantity(bookDto.getQuantity())
.build();
}
ayylmao123xdd
ayylmao123xdd2w ago
do u still have the old dependency setup for lombok
IamMax420
IamMax420OP2w ago
and here's the Book entity
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
@Table(name = "book", uniqueConstraints = {
@UniqueConstraint(columnNames = "title")
})
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false)
private Long id;
@Column(nullable = false)
private String author;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String category;
@Column(nullable = false)
private Integer pages;
@Column(nullable = false)
private Integer quantity;
}
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
@Table(name = "book", uniqueConstraints = {
@UniqueConstraint(columnNames = "title")
})
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false)
private Long id;
@Column(nullable = false)
private String author;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String category;
@Column(nullable = false)
private Integer pages;
@Column(nullable = false)
private Integer quantity;
}
ayylmao123xdd
ayylmao123xdd2w ago
that we were doing last time
IamMax420
IamMax420OP2w ago
nah this is a new project I'm doing microservices now 🤡
ayylmao123xdd
ayylmao123xdd2w ago
l0l
JavaBot
JavaBot2w ago
Ikr
Ikr
ayylmao123xdd
ayylmao123xdd2w ago
oops wrong message when u format code do 3 ticks and type java at the beginning of the message so it has color look
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
@Table(name = "book", uniqueConstraints = {
@UniqueConstraint(columnNames = "title")
})
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false)
private Long id;
@Column(nullable = false)
private String author;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String category;
@Column(nullable = false)
private Integer pages;
@Column(nullable = false)
private Integer quantity;
}
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
@Table(name = "book", uniqueConstraints = {
@UniqueConstraint(columnNames = "title")
})
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false)
private Long id;
@Column(nullable = false)
private String author;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String category;
@Column(nullable = false)
private Integer pages;
@Column(nullable = false)
private Integer quantity;
}
anyway you probably dont need to specify nullable false on each field instead you could do validation on the fields when you are creating the entity next show the pom file with lombok setup
JavaBot
JavaBot2w ago
Please format your code & make it more readable. For the java programming language, it should look like this:
```java public class Main { public static void main(String[] args){ System.out.println("Hello World!"); } ```
• These are backticks, not quotes.
IamMax420
IamMax420OP2w ago
for some reason it's not letting me post the pom.xml file I'm getting some discord error
ayylmao123xdd
ayylmao123xdd2w ago
o btw you can just do
@Column(unique = true)
@Column(unique = true)
to make it unique on the field
IamMax420
IamMax420OP2w ago
Damn alr
ayylmao123xdd
ayylmao123xdd2w ago
instead of that table annotation
IamMax420
IamMax420OP2w ago
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
oh it worked this time unbelieveable
ayylmao123xdd
ayylmao123xdd2w ago
truly crazy right
IamMax420
IamMax420OP2w ago
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>21</source>
<target>21</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>21</source>
<target>21</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
it's basically the same as the one we were figuring out yesterday
ayylmao123xdd
ayylmao123xdd2w ago
is it the same setup as last time oh
IamMax420
IamMax420OP2w ago
ye
ayylmao123xdd
ayylmao123xdd2w ago
i think it was like 3 days ago tho lol
IamMax420
IamMax420OP2w ago
idk I have dementia
IamMax420
IamMax420OP2w ago
lmaoo
ayylmao123xdd
ayylmao123xdd2w ago
whats ur java version
IamMax420
IamMax420OP2w ago
21
ayylmao123xdd
ayylmao123xdd2w ago
ok wait ill check something
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
is this part new or no i forgot nvm its not new ok so if you can try to get rid of the all args constructor annotation and see if that helps
IamMax420
IamMax420OP2w ago
that didn't work
ayylmao123xdd
ayylmao123xdd2w ago
did u import the right builder package btw lmao
IamMax420
IamMax420OP2w ago
yeah
IamMax420
IamMax420OP2w ago
No description
IamMax420
IamMax420OP2w ago
what the fuck I did not get that error before
ayylmao123xdd
ayylmao123xdd2w ago
ha
IamMax420
IamMax420OP2w ago
wtf does that even mean
ayylmao123xdd
ayylmao123xdd2w ago
it says you need no args constructor and all args constructor if i remember correctly
IamMax420
IamMax420OP2w ago
yeah I added them back and I'm still getting the error
ayylmao123xdd
ayylmao123xdd2w ago
but yea i was asking u to delete all args for testing r u using intellij
IamMax420
IamMax420OP2w ago
yeah
ayylmao123xdd
ayylmao123xdd2w ago
do you know how to run maven clean install
IamMax420
IamMax420OP2w ago
ye I did that like 50 times during past hour
ayylmao123xdd
ayylmao123xdd2w ago
lol did you refresh the pom too
IamMax420
IamMax420OP2w ago
how do u do that
ayylmao123xdd
ayylmao123xdd2w ago
you see the m on the right of your screen maven gui
IamMax420
IamMax420OP2w ago
ye ye
ayylmao123xdd
ayylmao123xdd2w ago
ok click it and at the top u should see the refresh icon that once u hover on it should say refresh all maven projects so click it
IamMax420
IamMax420OP2w ago
holy fuck it works
ayylmao123xdd
ayylmao123xdd2w ago
the button or the builder method lmao
IamMax420
IamMax420OP2w ago
bruh I thought mvn clean install will take care of all that the builder method
ayylmao123xdd
ayylmao123xdd2w ago
nice yea apparently you had some old cache or something
IamMax420
IamMax420OP2w ago
I'd get u a donut or something for the help but idk where u are and Im from Poland so I can give you some pierogi they're good asf
ayylmao123xdd
ayylmao123xdd2w ago
i want vodka ezzzzzzzzzzzzzzzzzz which one is the best that u make
IamMax420
IamMax420OP2w ago
I like absolut vodka, not sure if it's even polish lol I once drank vodka and beer at the same time and threw up so don't make the same mistake as me
ayylmao123xdd
ayylmao123xdd2w ago
lol i think absolut is russian try rasputin the one with 70 percent alcohol :SkullPixel:
IamMax420
IamMax420OP2w ago
💀 we have spirytus that's like 90-95%
ayylmao123xdd
ayylmao123xdd2w ago
o mamma mia but yea if u wanna know why mvn clean install didnt help ask his sudoness daniel cuz idk how to explain that one in detail
IamMax420
IamMax420OP2w ago
gotcha thanks again
JavaBot
JavaBot2w 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
JavaBot2w ago
Post Closed
This post has been closed by <@589517424093691905>.

Did you find this page helpful?