#Lombok @Builder error

124 messages · Page 1 of 1 (latest)

modern plume
#

I'm getting this error: java: cannot find symbol symbol: method builder() when using the .builder() method on an object that I previously marked with the @Builder annotation

timid laurelBOT
#

This post has been reserved for your question.

Hey @modern plume! 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.

frozen parcel
#

😱

#

thats truly a disaster

#

show the code where ur trying to use builder

modern plume
#

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();
}```
frozen parcel
#

do u still have the old dependency setup for lombok

modern plume
#

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; }

frozen parcel
#

that we were doing

#

last time

modern plume
#

nah this is a new project

#

I'm doing microservices now 🤡

frozen parcel
#

l0l

timid laurelBOT
#
Ikr
frozen parcel
#

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;
}
#

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

timid laurelBOT
#

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.

modern plume
#

for some reason it's not letting me post the pom.xml file

#

I'm getting some discord error

frozen parcel
#

o btw you can just do

#
@Column(unique = true)
#

to make it unique

#

on the field

modern plume
#

Damn

#

alr

frozen parcel
#

instead of that table annotation

modern plume
#
        <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

frozen parcel
#

truly crazy right

modern plume
#
        <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

frozen parcel
#

is it the same setup as last time

#

oh

modern plume
#

ye

frozen parcel
#

i think it was like 3 days ago tho

#

lol

modern plume
#

idk I have dementia

modern plume
#

lmaoo

frozen parcel
#

whats ur

#

java version

frozen parcel
#

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>
#

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

modern plume
#

that didn't work

frozen parcel
#

did u import the right builder package btw lmao

modern plume
#

yeah

#

what the fuck

#

I did not get that error before

frozen parcel
#

ha

modern plume
#

wtf does that even mean

frozen parcel
#

it says you need

#

no args constructor

#

and all args constructor

#

if i remember correctly

modern plume
#

yeah I added them back and I'm still getting the error

frozen parcel
#

but yea i was asking u to delete all args for testing

#

r u using intellij

modern plume
#

yeah

frozen parcel
#

do you know how to run maven clean install

modern plume
#

ye I did that like 50 times during past hour

frozen parcel
#

lol

#

did you refresh the pom too

modern plume
#

how do u do that

frozen parcel
#

you see the m

#

on the right of your screen

#

maven gui

modern plume
#

ye ye

frozen parcel
#

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

modern plume
#

holy fuck it works

frozen parcel
#

the button or the builder method

#

lmao

modern plume
#

bruh I thought mvn clean install will take care of all that

modern plume
frozen parcel
#

nice

#

yea apparently you had some old cache or something

modern plume
#

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

frozen parcel
#

i want vodka

#

ezzzzzzzzzzzzzzzzzz

#

which one is the best that u make

modern plume
#

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

frozen parcel
#

lol

#

i think absolut is russian

#

try rasputin the one with 70 percent alcohol

modern plume
#

💀

#

we have spirytus that's like 90-95%

frozen parcel
#

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

modern plume
#

gotcha

#

thanks again

timid laurelBOT
# modern plume thanks again

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.