java开发神器Lombok初识
一、前言
在我们使用java语言定义实体对象的时候,以前经常需要写set和get方法,会觉得很繁琐。偶然接触到一款神器叫Lombok的,可以帮我们很好的解决这种琐事。
二、步骤
1、在idea上安装Lombok插件
File-Settings-Plugins,搜索Lombok
下载后,需要重启idea生效
2、在pom文件添加相关依赖
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.20</version> <scope>provided</scope> </dependency>
三、测试类
import lombok.Data; @Data public class Text { private String content; }
idea编译之后的:
// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // package restassureddemo.weixin; public class Text { private String content; public Text() { } public String getContent() { return this.content; } public void setContent(String content) { this.content = content; } public boolean equals(Object o) { if (o == this) { return true; } else if (!(o instanceof Text)) { return false; } else { Text other = (Text)o; if (!other.canEqual(this)) { return false; } else { Object this$content = this.getContent(); Object other$content = other.getContent(); if (this$content == null) { if (other$content != null) { return false; } } else if (!this$content.equals(other$content)) { return false; } return true; } } } protected boolean canEqual(Object other) { return other instanceof Text; } public int hashCode() { int PRIME = true; int result = 1; Object $content = this.getContent(); int result = result * 59 + ($content == null ? 43 : $content.hashCode()); return result; } public String toString() { return "Text(content=" + this.getContent() + ")"; } }
说明生效
知道、想到、做到、得到
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)