- Project Lombok is a java library that automatically plugs into your
editor and build tools, spicing up your java. - Never write another getter or equals method again, with one
annotation your class has a fully featured builder, Automate your
logging variables, and much more.
spring boot 中的使用
- 引入依赖
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>compile</scope>
- 直接用注解的方式使用
@Data 可以自动为实体类生成getter setter toString equal constructor 等方法
@Getter @Setter 可以为属性生成getter setter 方法
@ToString(callSuper=true,exclude="someExecludeField")
@EqualAndHashCode(callSuper=true,exclude={"",""})
更多其实只是使用期日志记录:
@Slf4j 对于一个类使用即可用log变量来记录-log.info("")
注意 还可以使用@Log @Log4j等等 不同的日志产品有不同的实现