I've been using Lombok with IntelliJ for a while now. I have installed newest (v. 0.28) Lombok plugin, enabled annotation processing and added a Lombok dependency (v. 1.18.10) in pom.xml. It all worked well until today, when I wanted to implement the experimental @SuperBuilder.
I have a simple hierarchy:
@SuperBuilder
public class User {
private String a;
}
@SuperBuilder
public class Employee extends User {
private int b;
}
@SuperBuilder
public class Employer extends User {
private double c;
}
I wanted to set the fields from parent's class in child's builder, e.g.:
Employee.builder().a("Positive").b(1).build();
Employer.builder().a("Negative").c(-2.1).build();
At the first glance it all seems to work - there are no errors displayed when the file is open and the builder is fine. However after mvn clean compile I get the following result on every @SuperBuilder line (i.e. in each of those 3 classes):
Error:(20) java: cannot find symbol
What am I missing here? I tried updating Lombok plugin version and reinstalling it, but without any success.
I've faced same issue and adding @SuperBuilder
to the all "base" classes solved the issue.
Before:
abstract class Parent {
...
}
@SuperBuilder
class Child extends Parent {
...
}
After:
@SuperBuilder // <- addded
abstract class Parent {
...
}
@SuperBuilder
class Child extends Parent {
...
}
Ok, I found it. I missed that the User class was extending a basic class every entity in our application extends. It seemed so obvious and yet I didn't notice...
Anyway, I found out only by running the mvn clean install in terminal - the output was much more verbose that the one in IntelliJ and it pointed out this class. After adding @SuperBuilder annotation on top of it compilation was successful.
But @SuperBuilder(toBuilder=true) is the right way of using it.
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