1 在idea安装lombok插件
2 项目中导入lombok的jar包
maven中查找lombok
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.18</version>
<scope>provided</scope>
</dependency>
3 实体类加lombok注解
@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
@val
@var
@Data:包含(无参构造,get,set,toString,equals,hascode)
不加@Data注解
加上@Data
@AllArgsConstructor:包含有参构造
@NoArgsConstructor:无参构造
@ToString:添加toString()
@EqualsAndHashCode
@Getter:放在类上,所有字段都生成get方法,放在字段上,只有这个字段生成get方法