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用起来

  • 相关阅读:
    awk使用
    SQL VIEW(视图)
    crontab使用
    SecureCRT
    Python异常
    Python字符串
    Python字典,列表,元组
    Python路径
    vim插件
    Python类
  • 原文地址:https://www.cnblogs.com/yb38156/p/9913987.html
Copyright © 2011-2022 走看看