I'm using lombok project with Entity here is my example :
package com.company.entities;//<---------Note the package
import javax.persistence.Entity;
import javax.persistence.Id;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Entity
@Builder
@Getter @Setter @AllArgsConstructor @NoArgsConstructor @ToString
public class Client {
@Id
private long id;
private String firstName;
private String lastName;
}
So when I try to use in the same package, It works fine :
When I change the package for example to package com.company.controllers;
:
package com.company.controllers;//<---------Note the package
public class Mcve {
public static void main(String[] args) {
Client client = new Client.ClientBuilder()
.id(123)
.firstName("firstName")
.lastName("lastName")
.build();
}
}
I get an error :
ClientBuilder() is not public in com.company.entities.Client.ClientBuilder; cannot be accessed from outside package
I tried all the solution in this posts :
I test with lombok 1.16.18
and 1.16.20
.
When I create my own builder class it works fine, but when I use @Builder
it not, I know what does this mean, but no way, I can't arrive to solve this issue ! what should I do to solve this problem?
You don't have to instantiate the builder. Instead use:
Client client = Client.builder()
.id(123)
.firstName("firstName")
.lastName("lastName")
.build();
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