1-Lombok工具使用
2024-10-19 01:33:14
1.先给Eclispe安装Lombok插件
首先下载 lombok-1.16.6.jar 这个jar包 存放在系统任意盘里面 我这里是放在 c:\lombok-1.16.6.jar
运行命令
点击 Specify location 选择eclise软件的安装目录
选择好之后 点击instal/update按钮
打开我们eclispe软件的安装目录 里面会多出一个jar文件 lombok.jar
到此插件安装成功
复制eclispe软件下面的 lombok.jar文件到我们项目工程当中 构造环境Build Path
因为这个插件我们是经常用的到,所以我们也配置到eclispe User Libary当中去
配置步骤
Window --->Preferences --->搜索 User Libraries
然后给lombok 关联一个jar包
然后给我们项目配置插件
引用之后 代码就不会报错,
以后我们的其它也可以直接引用既可以
其实lombok 是帮助我们生成了这些方法,我们打开字节码来查看一下吧
打开的字节码如下显示
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: User.java package com.my.bean; public class User
{ private int id;
private String userName;
private String password; public int getId()
{
return id;
} public String getUserName()
{
return userName;
} public String getPassword()
{
return password;
} public void setId(int id)
{
this.id = id;
} public void setUserName(String userName)
{
this.userName = userName;
} public void setPassword(String password)
{
this.password = password;
} public boolean equals(Object o)
{
if (o == this)
return true;
if (!(o instanceof User))
return false;
User other = (User)o;
if (!other.canEqual(this))
return false;
if (getId() != other.getId())
return false;
Object this$userName = getUserName();
Object other$userName = other.getUserName();
if (this$userName != null ? !this$userName.equals(other$userName) : other$userName != null)
return false;
Object this$password = getPassword();
Object other$password = other.getPassword();
return this$password != null ? this$password.equals(other$password) : other$password == null;
} protected boolean canEqual(Object other)
{
return other instanceof User;
} public int hashCode()
{
int PRIME = 59;
int result = 1;
result = result * 59 + getId();
Object $userName = getUserName();
result = result * 59 + ($userName != null ? $userName.hashCode() : 43);
Object $password = getPassword();
result = result * 59 + ($password != null ? $password.hashCode() : 43);
return result;
} public String toString()
{
return (new StringBuilder("User(id=")).append(getId()).append(", userName=").append(getUserName()).append(", password=").append(getPassword()).append(")").toString();
} public User()
{
}
}
现在测试代码就是可以直接使用了
package com.my.test; import com.my.bean.User; public class Demo { /**
* @param args
*/
public static void main(String[] args) { User u=new User();
u.setUserName("刘诗华");
u.setPassword("xxxxxxxxxxx");
u.setId(100); } }
最新文章
- Integer to English Words
- PHPCMS后台密码忘记解决办法
- WebDriver中启动不同的浏览器
- C++学习26 运算符重载的概念和语法
- js中数组操作
- Android:AlertDialog对话框
- Swift计算属性
- I - Agri-Net - poj 1258
- windows2008无线网卡和.net3.5安装
- 《生活在Linux中》之:使用Bash就是使用Emacs
- kafka集群中常见错误的解决方法:kafka.common.KafkaException: Should not set log end offset on partition
- HDU4027 Can you answer these queries?(线段树 单点修改)
- https原理通俗了解
- Android官方技术文档翻译——开发工具的构建概述
- git 服务器 LINUX端的使用
- CP343-1 扩展ProfibusCPU 314C-2DP
- java 值传递 数组传递
- 牛客网某比赛 I 小乐乐学博弈 博弈论
- Nginx server之Nginx添加ssl支持
- js 实现遮罩某一部分