Eclipse中Lombok的安装和注解说明
Lombok 可用来帮助开发人员消除 Java 的重复代码,尤其是对于简单的 Java 对象(POJO),比如说getter/setter/toString等方法的编写。它通过注解实现这一目的。
官网:https://projectlombok.org
一、Eclipse中Lombok的安装
1、官网下载jar包当前版本是1.18.4,下载下来是一个lombok.jar
2、将lombok.jar移到eclipse的安装目录,即eclipse.in的同级目录
3、在eclipse.in文件最后加入下面两行
-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar
备注:
如果使用Lombok程序报错,可以点击eclipse菜单的Project选项的clean,清理一下即可。
二、Lombok注解说明
注解详见官网https://projectlombok.org/features/all
val
Finally! Hassle-free final local variables.
var
Mutably! Hassle-free local variables.
@NonNull
or: How I learned to stop worrying and love the NullPointerException.
@Cleanup
Automatic resource management: Call your close()
methods safely with no hassle.
@Getter/@Setter
Never write public int getFoo() {return foo;}
again.
@ToString
No need to start a debugger to see your fields: Just let lombok generate a toString
for you!
@EqualsAndHashCode
Equality made easy: Generates hashCode
and equals
implementations from the fields of your object..
@NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor
Constructors made to order: Generates constructors that take no arguments, one argument per final / non-nullfield, or one argument for every field.
@Data
All together now: A shortcut for @ToString
, @EqualsAndHashCode
, @Getter
on all fields, and @Setter
on all non-final fields, and @RequiredArgsConstructor
!
@Value
Immutable classes made very easy.
@Builder
... and Bob's your uncle: No-hassle fancy-pants APIs for object creation!
@SneakyThrows
To boldly throw checked exceptions where no one has thrown them before!
@Synchronized
synchronized
done right: Don't expose your locks.
@Getter(lazy=true)
Laziness is a virtue!
@Log
Captain's Log, stardate 24435.7: "What was that line again?"
experimental
Head to the lab: The new stuff we're working on.
相关文章
- [Eclipse插件] 安装和使用JD-Eclipse插件
- eclipse的安装
- VMware 9.0.1安装Mac OS X Mountain Lion 10.8.2
- eclipse插件安装失败的列表如何清除-一个困扰很久的问题
- Eclipse中Spring插件的安装
- KextWizard 的使用方法;以及Kext安装的几种工具下载
- Activiti的Eclipse插件安装指南
- EasyDSS RTMP流媒体解决方案之Windows服务安装方案
- kubesphere3.0的安装完整文档
- k8s安装kubesphere的环境准备:资源规划、默认存储类StorageClass(nfs-client-provisioner)
- CentOS 7.3安装GNOME桌面步骤
- 成功解决安装cuda的时候,下载的文件自动消失,并且出现An unknown error has occurred
- Computer:Microsoft Office Visio2021的简介、安装、使用方法图文教程之详细攻略
- 如何安装python模块, python模块安装失败的原因以及解决办法
- Eclipse安装教程
- (2022版)一套教程搞定k8s安装到实战 | TLS Bootstrap初始化流程
- 安装Google三件套
- eclipse luna 无法安装veloeclipse问题
- eclipse控制流图插件——cfg的安装和使用