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. Project Lombok是一个java库,它可以自动插入到编辑器和构建工具中,增强java的性能。 永远不要再写另一个getter或equals方法,只要有一个注释,你的类就有一个功能齐全的构建器,自动记录变量,等等。
java libraryplugsbuild toolswith one annotation your class使用步骤:
在IDEA中安装Lombok插件在项目中导入Lombok的jar包 <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.12</version> </dependency> 在实体类上加注解即可 @Data @AllArgsConstructor @NoArgsConstructor public class User { private int id; private String name; private String pwd; }@Getter and @Setter @FieldNameConstants @ToString @EqualsAndHashCode @AllArgsConstructor, @RequiredArgsConstructor and @NoArgsConstructor @Log, @Log4j, @Log4j2, @Slf4j, @XSlf4j, @CommonsLog, @JBossLog, @Flogger, @CustomLog @Data @Builder @SuperBuilder @Singular @Delegate @Value @Accessors @Wither @With @SneakyThrows
说明: @Data:无参构造,get,set,tostring,hashcode,equals @AllArgsConstructor @NoArgsConstructor