Lombok的常用注解

182 阅读1分钟

1.Lombok简介

官方介绍 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.

大概的意思:Lombok是一个Java库,能自动插入编辑器并构建工具,简化Java开发。通过添加注解的方式,不需要为类编写getter或eques方法,同时可以自动化日志变量。官网链接

简而言之:Lombok能以简单的注解形式来简化java代码,提高开发人员的开发效率。 博客及源码GitHub链接

2.常用注解:

1.@Data //这是一个Lombok库提供的注解,它会自动为类生成getter和setter方法,以及equals、canEqual、hashCode、toString等方法。

2.@AllArgsConstructor //这是一个Lombok库提供的注解,它会自动为类生成一个包含所有参数的构造函数。

3.@NoArgsConstructor //这是一个Lombok库提供的注解,它会自动为类生成一个无参构造函数。