1、File-Settings-Plugins-Brows Repositories-输入lombok-install

2、重启idea

3、添加maven依赖

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.16.10</version>
</dependency>

4、用法

看下官方Features

@Getter and @Setter
@FieldNameConstants
@ToString
@EqualsAndHashCode
@AllArgsConstructor, @RequiredArgsConstructor and @NoArgsConstructor
@Log, @Log4j, @Log4j2, @Slf4j, @XSlf4j, @CommonsLog, @JBossLog, @Flogger
@Data
@Builder
@Singular
@Delegate
@Value
@Accessors
@Wither
@SneakyThrows
from Intellij 14.1 @val
from Intellij 15.0.2 @var
from Intellij 14.1 @var
from Intellij 2016.2 @UtilityClass
Lombok config system
Code inspections
Refactoring actions (lombok and delombok)

 

我们最关注的的几个注解:

@Data即可

Logger.getLogger(LogExample.class.getName());

@Builder 返回每个属性值的Builder,不用自己再去实现

 

使用此插件后,一个普通的Bean至少减少一半的代码量,出错几率也大大降低,pick用起来

相关文章:

  • 2022-12-23
  • 2021-12-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-05-15
相关资源
相似解决方案