@SuperBuilder error: cannot find symbol in Lombok

Issue

I’m having trouble using the experimental @SuperBuilder annotation with Lombok in my project. I have installed the newest version of the Lombok plugin (v. 0.28), enabled annotation processing, and included the Lombok dependency (v. 1.18.10) in my pom.xml. I have a simple hierarchy of classes in which the parent class is annotated with @SuperBuilder:

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

The code appears to work properly within the editor, but when I try to compile, I get a Error:(20) java: cannot find symbol error for each of the @SuperBuilder annotations. I have tried updating the Lombok plugin and reinstalling it, but so far I have not been successful.

Answer

You need to add the Lombok dependency to the annotation processor path in your pom.xml file. Add the following plugin to your pom.xml:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>3.8.0</version>
   <configuration>
      <annotationProcessorPaths>
         <path>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
         </path>
      </annotationProcessorPaths>
   </configuration>
</plugin>

This will add the Lombok dependency to the annotation processor path and allow the @SuperBuilder annotation to be processed during compilation.