zoukankan      html  css  js  c++  java
  • IDEA 安装lombok及使用

    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)

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

    @Getter  @Setter @ToString @AllArgsConstructor,这4个注解直接用@Data即可

    @Slf4j,省去之前用的Logger.getLogger(LogExample.class.getName());

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

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

  • 相关阅读:
    linux命令学习之:cd
    SSH原理与运用
    java遍历当前会话所有Session
    spring+quartz报错:Table 'XXXX.QRTZ_TRIGGERS' doesn't exist
    python检测编码
    python安装模块
    python网络爬虫
    系统编码 python编码
    python 中文路径
    python读取文件乱码
  • 原文地址:https://www.cnblogs.com/yb38156/p/9913987.html
Copyright © 2011-2022 走看看