lombok使用

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.
理解:
是一个构建工具,java库,自动化插件,可以通过添加注解实现再也不需要写getter和equals方法了

lombok使用

intellij下载插件

image-20210426171034496

导入jar包

<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.16</version>
    <scope>provided</scope>
</dependency>

有哪些注解

image-20210426171453472
@Getter and @Setter	【getter方法和setting方法】
@FieldNameConstants	
@ToString	【toString方法】
@EqualsAndHashCode	【squals方法和hashcode重写方法】
@AllArgsConstructor 【全部参数构造函数】, @RequiredArgsConstructor and @NoArgsConstructor【无参构造方法】
@Log, @Log4j, @Log4j2, @Slf4j, @XSlf4j, @CommonsLog, @JBossLog, @Flogger, @CustomLog
@Data【无参构造,get,set,toString,hascode,equals全部自动化】
@Builder
@SuperBuilder
@Singular
@Delegate
@Value
@Accessors
@Wither
@With
@SneakyThrows
@val
@var
experimental @var
@UtilityClass
@ExtensionMethod (Experimental, activate manually in plugin settings)
Lombok config system

使用实例

  • 使用前
image-20210426172243356
  • 使用后
image-20210426172320365
posted @ 2021-06-07 17:31  Coder-Wang  阅读(71)  评论(0编辑  收藏  举报