eclipse环境下:lombok安装及使用

简介: lombok官网:https://projectlombok.org/ jar包下载路径:https://projectlombok.org/download lombok features:https://projectlombok.

lombok官网:https://projectlombok.org/
jar包下载路径:https://projectlombok.org/download
lombok features:https://projectlombok.org/features/all

lombok:通过注解方式减少POJO类的getter和setter等方法来消除冗余代码量

 

安装
1.下载 lombok.jar
2.官网说是可以双击安装,,,我用这种方法不可行
2.手动安装
(1)将lombok.jar移到eclipse的安装目录
这里写图片描述

(2)在eclipse.in文件最后加入下面两行

-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar

=============
-javaagent:xxx.jar 的jar名称 需要与根目录下的jar名一致,
不一致,可能会出现eclipse无法启动的情况。

(3)重启eclipse,进行代码测试

原始java代码:

public class NoteTest {

    private int noteId;
    private String title; private String content; private int typeId; }

class文件反编译后:

public class NoteTest
{

    private int noteId;
    private String title; private String content; private int typeId; public NoteTest() { 

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
加入lombok注解后的java代码:

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(exclude="typeId") public class NoteTest { private int noteId; private String title; private String content; private int typeId; }

加注解,经反编译:

public class NoteTest
{

    private int noteId; private String title; private String content; private int typeId; public int getNoteId() { return noteId; } public String getTitle() { return title; } public String getContent() { return content; } public int getTypeId() { return typeId; } public void setNoteId(int noteId) { this.noteId = noteId; } public void setTitle(String title) { this.title = title; } public void setContent(String content) { this.content = content; } public void setTypeId(int typeId) { this.typeId = typeId; } public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof NoteTest)) return false; NoteTest other = (NoteTest)o; if (!other.canEqual(this)) return false; if (getNoteId() != other.getNoteId()) return false; Object this$title = getTitle(); Object other$title = other.getTitle(); if (this$title != null ? !this$title.equals(other$title) : other$title != null) return false; Object this$content = getContent(); Object other$content = other.getContent(); if (this$content != null ? !this$content.equals(other$content) : other$content != null) return false; return getTypeId() == other.getTypeId(); } protected boolean canEqual(Object other) { return other instanceof NoteTest; } public int hashCode() { int PRIME = 59; int result = 1; result = result * 59 + getNoteId(); Object $title = getTitle(); result = result * 59 + ($title != null ? $title.hashCode() : 43); Object $content = getContent(); result = result * 59 + ($content != null ? $content.hashCode() : 43); result = result * 59 + getTypeId(); return result; } public NoteTest() { } public NoteTest(int noteId, String title, String content, int typeId) { this.noteId = noteId; this.title = title; this.content = content; this.typeId = typeId; } public String toString() { return (new StringBuilder("NoteTest(noteId=")).append(getNoteId()).append(", title=").append(getTitle()).append(", content=").append(getContent()).append(")").toString(); } }
欢迎大家一起说出自己的想法。
目录
相关文章
|
4月前
|
Java Linux Android开发
linux下eclipse安装
linux下eclipse安装
68 0
|
4月前
|
Java Linux 开发工具
怎样下载安装Eclipse并配置开发环境?
Eclipse是一款非常流行的Java开发工具,它本身是开源的,适合多种多样的开发场景,深受Java开发者们的喜爱。今天我就跟大家介绍一下如何下载安装Eclipse,以及如何配置Eclipse的开发环境。
125 0
|
4月前
|
Java Android开发
在Eclipse环境下调试Java程序
在Eclipse环境下调试Java程序
53 1
|
4月前
|
存储 Java 开发工具
在Eclipse配置安装Android详细教程(新手)
在Eclipse配置安装Android详细教程(新手)
119 1
|
4月前
|
Java Android开发
【Java开发指南 | 第十八篇】Eclipse安装教程
【Java开发指南 | 第十八篇】Eclipse安装教程
47 2
|
3月前
蓝易云 - MyEclipse6.5安装m2eclipse方法
注意:由于MyEclipse 6.5是一个较旧的版本,可能无法支持最新版本的m2eclipse插件,因此在下载时,请尽量选择与MyEclipse 6.5兼容的m2eclipse版本。
31 0
|
4月前
|
IDE Java 开发工具
【Eclipse安装及使用(面向小白)】
【Eclipse安装及使用(面向小白)】
61 1
|
4月前
|
IDE Java 开发工具
【 编程 IDE】Eclipse软件的安装
【 编程 IDE】Eclipse软件的安装
61 1
|
4月前
|
Java Android开发
eclipse安装windowbuilder
eclipse安装windowbuilder
|
4月前
|
XML Java Maven
eclipse 、idea 安装activiti插件
eclipse 、idea 安装activiti插件