Lombok errors – can not find symbol, variable xyz not initialized in the default constructor, etc in Idea

Lombok errors - can not find symbol, variable xyz

If you’re encountering errors like:

  • java: variable xyz not initialized in the default constructor
  • java: cannot find symbol (for methods like getId(), etc.)
  • Other errors related to Lombok-generated methods

…even though IntelliJ IDEA suggests the methods in auto-complete, you’re not alone. This issue can be frustrating because everything seems correct—Lombok is installed, dependencies are added, annotation processing is enabled—but the project still fails to compile.

I ran into this exact problem recently, and after trying everything from reinstalling Lombok to changing compiler settings, I finally found the root cause.


Possible Causes and Fixes for Lombok Errors in IntelliJ IDEA

Before diving into the unusual cause I discovered, let’s go over the basic checks that can solve Lombok-related issues:

1. Check Lombok Dependency

Make sure you’ve added Lombok to your project:

For Maven (pom.xml)

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.30</version>
    <scope>provided</scope>
</dependency>

Run:

mvn clean install

to ensure dependencies are properly downloaded.

For Gradle (build.gradle.kts)

dependencies {
    compileOnly("org.projectlombok:lombok:1.18.30")
    annotationProcessor("org.projectlombok:lombok:1.18.30")
}

Run:

gradle build

2. Enable Annotation Processing in IntelliJ IDEA

  • Go to Settings > Build, Execution, Deployment > Compiler > Annotation Processors
  • Make sure “Enable annotation processing” is checked.

3. Use javac as Compiler

  • Go to Settings > Build, Execution, Deployment > Compiler > Java Compiler
  • Ensure “Use compiler” is set to javac.
  • Apply and restart IntelliJ IDEA.

4. The Real Fix (If Everything Else Fails)

If you’ve tried all the above and still face errors, check your annotation processor settings. Here’s what happened in my case:

  • IntelliJ IDEA was using a custom processor path instead of the correct default classpath.
  • Go to Settings > Build, Execution, Deployment > Compiler > Annotation Processors
  • Under Processor Path, IntelliJ IDEA was selecting a random path instead of the default project classpath.
  • Solution:
  • Remove any custom processor paths and set it to “Obtain from project classpath”.
  • Apply changes and restart IntelliJ IDEA.

This instantly fixed all Lombok-related compilation errors for me.


Conclusion

Lombok errors in IntelliJ IDEA often result from annotation processing issues. If you’re facing these errors:

Check Lombok dependency in pom.xml or build.gradle
Enable annotation processing in IntelliJ IDEA
Use javac as the compiler
Check annotation processor paths and remove any custom paths

By following these steps, you should be able to resolve any Lombok-related issues in IntelliJ IDEA.


Keywords

  • Lombok not working in IntelliJ IDEA
  • Cannot find symbol Lombok IntelliJ
  • Lombok getter setter not recognized
  • Variable not initialized in default constructor IntelliJ
  • IntelliJ annotation processing error Lombok
  • Fix Lombok compilation errors IntelliJ
  • Lombok annotation processing not working in IDEA

If this helped, feel free to share or drop a comment below with any additional solutions you’ve found!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *