lombok在spring 中的使用

  • 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.

spring boot 中的使用

  • 引入依賴
<groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
            <scope>compile</scope>
  • 直接用註解的方式使用
@Data 可以自動爲實體類生成getter setter toString equal constructor 等方法
@Getter @Setter 可以爲屬性生成getter setter 方法
@ToString(callSuper=true,exclude="someExecludeField")
@EqualAndHashCode(callSuper=true,exclude={"",""})

更多其實只是使用期日誌記錄:
@Slf4j 對於一個類使用即可用log變量來記錄-log.info("")

注意 還可以使用@Log @Log4j等等 不同的日誌產品有不同的實現

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章