1、下載lombok http:///download.html 2、點擊安裝: 如果eclipse沒有安裝到默認(rèn)目錄,那么需要點擊Specify選擇eclipse的安裝文件,然后Install即可完成安裝 3、如果程序還在報錯,那么點擊在eclipse的Project選項的clean 4、使用: Lombok的特色是根據(jù)annotation創(chuàng)建一些代碼,以減少重復(fù)代碼的數(shù)量,它提供了以下幾個annotation:
5、實例: @ToString(exclude="color") public @Data class Lure { private String name; private int size; private String color; private String style; @Data是實現(xiàn)所有的成員的Get和Set方法 @ToString(exclude="color") 是ToString時候排除color成員變量 注意調(diào)用flag成員變量時候,是isFlag方法 |
|