Lombok installation notes and common

Brief introduction

lombok  provides a simple form of annotations to help us simplify eliminate some but must have looked very bloated java code.

installation

Idea

Eclipse/MyEclipse

  1. Copy the file to the next lombok.jar myeclipse.ini / eclipse.ini same folder directory
  2. Open eclipse.ini / myeclipse.ini, insert the following two lines in the final surface and save: 
    1. -Xbootclasspath/a:lombok.jar 
    2. -javaagent:lombok.jar 
  3. Restart eclipse / myeclipse

Common Annotations

@Data  annotation on the class; class provides the getting and setting attributes for all methods, also provided equals, canEqual, hashCode, toString method

@Setter  : annotation on the property; setting property provides a method for the

@Getter  : annotation on the property; getting property provides a method for the

Log4j @  : annotation on the class; log4j provides a log object class attribute is called log

@NoArgsConstructor  : annotation on the class; method configured to provide a class of non-reference

@AllArgsConstructor  : annotation on the class; class provide a full-argument constructor

@Cleanup  : you can turn off the flow

@Builder  : annotated class constructors add mode

@Synchronized  : add a genlock

@SneakyThrows  : equivalent to try / catch to catch exceptions

@NonNull  : If you add a comment to this argument to the argument is null throws null pointer exception

@Value: Notes and @Data similar, except that it will default to all member variables defined as private final modification, and does not generate a set method.

Reference Documents

The official document:  https://projectlombok.org/features/all

lombok comment introduce  http://blog.csdn.net/sunsfan/article/details/53542374

Lombok introduction and use  http://www.cnblogs.com/holten/p/5729226.html

Published 75 original articles · won praise 48 · Views 350,000 +

Guess you like

Origin blog.csdn.net/KingJin_CSDN_/article/details/100581839