Project Lombok
@RequiredArgsConstructor
Used to achieve Constructor Injection without manually writing a constructor.
For Lombok
Lombok is not perfect, but it’s so much more than @Value… @SneakyThrows, @ToBuilder/@With, @Delegate, @xxxConstructor and many more annotations are invaluable.
Against Lombok
Lombok was brilliant for its time. But Java has evolved. Records are here. Mapping can be safe and explicit. You don’t need a plugin that writes Java for you. You need one that helps you write better Java.
- Replace
@Data
with Java Records. - Replace those clunky
ModelMapper/Lombok DTO combinations
with MapStruct or just plain-old java mapping. - Can you replace
@Builders? Can you use MapStruct’s builders?
Potential pitfalls
See Maven - errors
Alternatives
Project Lombok is a popular Java library that reduces boilerplate code by using annotations for things like getters, setters, constructors, builders, and more. However, it does so by manipulating the Java compiler internals, which can cause issues with IDEs, build tools, or during debugging. If you’re looking for alternatives to Lombok—either to avoid its magic or to improve portability and readability—here are some common options:
Manual Coding (Vanilla Java)
Write all boilerplate code explicitly.
Pros:
- No dependencies.
- Full IDE and toolchain compatibility.
- Clear and explicit behavior.
Cons:
- Verbose.
- Error-prone and time-consuming.
Java Records (Java 14+)
Use Java record classes for immutable data carriers.
public record Person(String name, int age) {}
Pros:
- Built into the language.
- Generates constructor, accessors, equals(), hashCode(), toString() automatically.
- Ideal for DTOs and simple data classes.
Cons:
- Immutable only.
- Limited customization.
- Only available in Java 14+ (finalized in Java 16).
Kotlin (Alternative JVM Language)
Use Kotlin to reduce boilerplate via language features.
data class Person(val name: String, val age: Int)
Pros:
- Concise syntax.
- Richer language features.
- Interoperable with Java.
Cons:
- Requires language migration.
- Mixed Java/Kotlin builds can introduce complexity.
Immutables library
AutoValue (by Google)
Tags
TODO
- We Fired Lombok and Hired MapStruct + Records. https://medium.com/javarevisited/we-fired-lombok-and-hired-mapstruct-records-c722ab631354
- Lombok in 2025: Why This Boilerplate Buster Remains Essential for Java Devs https://towardsdev.com/lombok-in-2025-why-this-boilerplate-buster-remains-essential-for-java-devs-aac8b5417bd4
- Don’t use Lombok https://medium.com/@vgonzalo/dont-use-lombok-672418daa819
- Should you still be using Lombok? https://www.reddit.com/r/java/comments/z1fgj7/should_you_still_be_using_lombok/