Lombok is not working in Spring Tool Suite (STS). This usually happens because Lombok needs to be explicitly integrated with your IDE. Let me walk you through it step by step:
1- Check Lombok dependency in pom.xml
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency>
2- Run Lombok installer
Open a terminal/command prompt and Locate the Lombok JAR inside your .m2
:
Run:
java -jar lombok-1.18.38.jar
- It will open a small Lombok Installer window.
- Click Specify Location → point it to your STS installation folder (e.g.,
C:\Users\<your-user>\sts-4.x.x.RELEASE
). - Select SpringToolSuite4.ini.
- Click Install/Update.
This adds Lombok as a -javaagent
entry in your SpringToolSuite4.ini
.
3- Verify Installation
Open SpringToolSuite4.ini
(same folder as SpringToolSuite4.exe
) and check for a line like:
-javaagent:C:\Users\<your-user>\sts-4.x.x.RELEASE\lombok.jar
If not present, add it manually.
4- Install APT (Annotation Processing) plugin in STS
- Go to:
Help → Eclipse Marketplace
- Search for APT or m2e-apt (full name: Maven Integration for Eclipse JDT APT).
- Install m2e-apt.
- Restart STS.
5- Enable Annotation Processing
After restart, you’ll now see the menu:
- Right click your project →
Properties
- Go to:
Java Compiler → Annotation Processing
- Check ✅ Enable annotation processing
- Check ✅ Enable project specific settings
- Also go to:
Java Compiler → Annotation Processing → Factory Path
- Verify Lombok JAR is listed there (if not, add it manually from your Maven/Gradle cache, e.g.
~/.m2/repository/org/projectlombok/lombok/1.18.xx/lombok-1.18.xx.jar
).
- Verify Lombok JAR is listed there (if not, add it manually from your Maven/Gradle cache, e.g.
6- Update Project
- Run:
Right click → Maven → Update Project
- Do a
Project → Clean
→Rebuild
.
7- Verify
Try a simple Lombok class:
import lombok.Getter; import lombok.Setter; public class Employee { @Getter @Setter private String name; }
In main():
Employee e = new Employee(); e.setName("Rupendra"); System.out.println(e.getName());
If STS still shows red errors, do:
Alt+Shift+O
→ Organize Imports- Rebuild once more.
✅ If no error → Lombok is working.