Mybatis-06-Lombok

偷懒神器Lombok

1. 什么是Lombok?

  • java library

  • plugs

  • build tools

2.使用步骤:

  1. 在IDEA中安装Lombok插件

  2. 在项目中导入lombok的jar包

 <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
 <dependency>
     <groupId>org.projectlombok</groupId>
     <artifactId>lombok</artifactId>
     <version>1.18.10</version>
     <scope>provided</scope>
 </dependency>
  1. 在实体类上加注解即可!

 @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

3. 结论

从此省去get set 构造器。

原文地址:https://www.cnblogs.com/CodeHuba/p/13474630.html