Skip to content

How to Fix Lombok Not Working in Eclipse or IntelliJ

DodaTech 2 min read

In this tutorial, you'll learn about How to Fix Lombok Not Working in Eclipse or IntelliJ. We cover key concepts, practical examples, and best practices.

The Problem

Your IDE shows compilation errors like The method getFirstName() is undefined or @Data cannot be resolved to a type even though Lombok is in your pom.xml or build.gradle. The IDE runs its own compilation process separate from Maven or Gradle, and Lombok requires an annotation processor to be explicitly enabled in the IDE settings. Without it, the generated getters, setters, constructors, and builders are invisible to the editor.

Quick Fix

1. Verify Lombok is declared correctly in your build file

In pom.xml:

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

In build.gradle:

compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'

testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'

2. IntelliJ โ€” Enable annotation processing

Open Settings:

File โ†’ Settings โ†’ Build, Execution, Deployment โ†’ Compiler โ†’ Annotation Processors
โ†’ Check "Enable annotation processing"
โ†’ Select "Obtain processors from project classpath"
โ†’ Set "Processor path" to your project's Maven/Gradle dependency cache
โ†’ Apply โ†’ OK

Rebuild the project:

mvn clean compile

Expected output:

[INFO] BUILD SUCCESS

3. Eclipse โ€” Install the Lombok agent

Run the Lombok JAR installer:

java -jar lombok.jar install /path/to/eclipse/eclipse.ini

This adds -javaagent:/path/to/lombok.jar to your eclipse.ini. Restart Eclipse with:

/path/to/eclipse/eclipse -clean

4. Create a quick test to verify Lombok works

import lombok.Data;
import lombok.Builder;

@Data
@Builder
public class User {
    private String firstName;
    private String lastName;
    private int age;

    public static void main(String[] args) {
        User user = User.builder()
            .firstName("Alice")
            .lastName("Smith")
            .age(30)
            .build();
        System.out.println(user.getFirstName());
    }
}

If Lombok is configured correctly, this compiles and runs without errors.

Expected output:

Alice

5. Check the Maven dependency tree

mvn dependency:list | grep lombok

Expected output:

org.projectlombok:lombok:jar:1.18.30:provided

6. Reimport Maven/Gradle project in the IDE

In IntelliJ, click the Maven tool window โ†’ refresh icon (circular arrows). In Eclipse, right-click the project โ†’ Maven โ†’ Update Project.

7. Run a standalone test to confirm Lombok generates code

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TestLombok {
    public static void main(String[] args) {
        log.info("Lombok is working!");
    }
}

If this compiles and prints the log line, Lombok is configured correctly.

8. Check for IDE cache issues

# IntelliJ: Invalidate caches and restart
File โ†’ Invalidate Caches / Restart...

# Eclipse: Clean the project
Project โ†’ Clean...

After cache invalidation, the IDE re-scans annotations and picks up Lombok processing again.

Prevention

  • Add Lombok to both compileOnly and annotationProcessor in Gradle (or provided scope in Maven)
  • Keep the Lombok IDE plugin version matched with the Lombok library version in your build file
  • Share .idea/ folder (or Eclipse project files) via version control to propagate annotation processor settings
  • Use delombok if you need to share generated code with team members who do not use Lombok
  • Add Lombok as a dependency in the very first commit of every new project

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro