Is it safe to use Project Lombok?

I tried various things about Lombok. It may be a reference when you adopt it in the project.

Brief description of Lombok

Lombok is an open source library that simplifies Java-specific redundant code (boilerplate code) just by annotating.

It automatically generates “code to write repeatedly” such as getter, setter, toString, equals at compile time.


  • Boiler plate code can be excluded from the code.
  • The accessor method does not stay old when changing the field name.
  • Logic in accessor method is not buried.
  • An appropriate value tends to appear in the test coverage.


  • @ToStringThere is a danger of becoming a circular reference. 
    → In that case, you can exclude it with exclude. 
    For details, see here → StackOverflow – toString method when using Lombok
  • When changing the field name, the reference destination of the accessor method can not be changed. 
    → It is necessary to take measures such as changing from automatic generation of IDE Getter / Setter by refactoring function.

Installation method

Download lombok.jar from the following site and run it.
Install / Update by specifying the same directory as eclipse.exe at Specify Location.

* For NetBeans, you can use it normally if you use Maven without manipulating jar or anything.

Below, how to write Maven. 
※ The scope must be provided.

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

Coding Standards

Because of its nature, Lombok is thought to change the sense of coding so far,

Dynamic typing

val list = new ArrayList <String> (); // Immutable local variable

Data model related

@Getter, @Setter, @ToString, @EqualsAndHashCode, @Data, @Value@NoArgsConstructor, @RequiredArgsConstructor, 

* AccessLevel, lazy, exclude, staticName = “of” can be used as an argument of the annotation.

Object creation related

@Builder, @Singular, @NonNull, @Wither, 

* In the case of Builder, you can change the names of generated class names and static method names that return instances, but in 
principle, do not set them. 
* CleanUp, if you use the try-with-resouces sentence preferentially, it is unnecessary in most cases, but there are 
still things that have not implemented Closable, so we can use it only when that case comes out.


@Synchronized, @Log4j2, 

* When using SneakyThrows, specify Throwable as a non-inspection exception.

Use prohibited

Under the lombok.experimental package 
→ Since there are a lot of experimental functions, the possibility that specification changes will be made in the future is sufficiently high. 
Example) Accessors (fluent = true), UtilityClass, and so on.