当前位置:网站首页>Lombok plug-in
Lombok plug-in
2022-07-07 05:35:00 【PIKapikaaaa】
Lombok plug-in unit
lombok Plug in introduction
lombok Is a plug-in , The purpose is to use annotations to give fields in your class , Automatically add attribute constructors ,ToString Method ,Equals Methods, etc. .
The more convenient point is , When you change fields ,lombok Changes will occur immediately to maintain consistency with your code .
frequently-used lombok Note introduction
@Getter : Can automatically generate parameters getter Method .
@Setter : Can automatically generate parameters setter Method
@ToString : call toString() Method , You can output the values of all attributes in the entity class
@RequiredArgsConstructor: Will generate a containing constant , And the logo NotNull How to construct the variables of . The generated constructor is private private. This one is seldom used .
@EqualsAndHashCode
1. It will generate equals and hashCode Method
2. Non static attributes are used by default
3. Can pass exclude Parameters exclude attributes that do not need to be generated
@EqualsAndHashCode(exclude = {“ Fields in the table 1”, “ Fields in the table 2”})
4. Can pass of Parameter to specify the attribute to be generated
@EqualsAndHashCode(of = {“ Fields in the table 1”, “ Fields in the table 2”})
5. By default, it does not call the methods of the parent class , Only use the attributes defined by this class to operate , have access to callSuper=true To solve , Will be in @Data I'll explain it in .
@Data: This annotation is actually a combination of the above five annotations —@Getter、@Setter、@RequiredArgsConstructor、@ToString、@EqualsAndHashCode
@NoArgsConstructor: Generate a parameterless construction method .
@AllArgsConstructor: Generate a constructor that contains all variables .
@Value: This annotation should be consistent with Spring Of @Value Annotation distinction ,Spring Is to read the content from the configuration file , This annotation is that all fields in the class are declared as private final type , Only generates Getter Method , Will not generate Setter Method , Rarely used .
@Cleanup: It is mainly used to turn off the use of resources .
idea install lombok plug-in unit
First we need to install IntelliJ IDEA Medium lombok plug-in unit .
open IntelliJ IDEA Then click... In the menu bar File–>Settings, Or use shortcut keys Ctrl+Alt+S Go to the settings page
Restart after installation idea—【 I am idea Version is 2021】
lombok Use of plug-ins
@Data
@AllArgsConstructor
@NoArgsConstructor
// Used to represent the mapping relationship between entity classes and database tables , When the entity class name is different from the name of the table, you must add @TableName
@TableName("user")
public class User {
// Indicates that the database self increment strategy is used
@TableId(type = IdType.AUTO)
private Long id;
// When the attribute name in the entity class is inconsistent with the field name in the database , have access to annotation :@TableField To represent the mapping relationship
@TableField("name")
private String username;
private Integer age;
private String email;
// @TableField(exist = false) Express There is no such field in the database table , Mapping transformation sql Statement will not spell this field
@TableField(exist = false)
private Date birthday;
public User(String name, Integer age, String email) {
this.username = name;
this.age = age;
this.email = email;
}
}
me = name;
this.age = age;
this.email = email;
}
}
边栏推荐
- 基于 hugging face 预训练模型的实体识别智能标注方案:生成doccano要求json格式
- Let f (x) = Σ x^n/n^2, prove that f (x) + F (1-x) + lnxln (1-x) = Σ 1/n^2
- 消息队列:消息积压如何处理?
- 基于NCF的多模块协同实例
- When deleting a file, the prompt "the length of the source file name is greater than the length supported by the system" cannot be deleted. Solution
- Educational Codeforces Round 22 B. The Golden Age
- 不同网段之间实现GDB远程调试功能
- 删除文件时提示‘源文件名长度大于系统支持的长度’无法删除解决办法
- 漏电继电器JELR-250FG
- MySQL数据库学习(7) -- pymysql简单介绍
猜你喜欢
导航栏根据路由变换颜色
利用OPNET进行网络指定源组播(SSM)仿真的设计、配置及注意点
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
Egr-20uscm ground fault relay
Initial experience of annotation
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
Make web content editable
《2》 Label
Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
English语法_名词 - 所有格
随机推荐
JVM(二十) -- 性能监控与调优(一) -- 概述
[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training
消息队列:重复消息如何处理?
分布式全局ID生成方案
实现网页内容可编辑
Taobao commodity details page API interface, Taobao commodity list API interface, Taobao commodity sales API interface, Taobao app details API interface, Taobao details API interface
DJ-ZBS2漏电继电器
论文阅读【Semantic Tag Augmented XlanV Model for Video Captioning】
Intelligent annotation scheme of entity recognition based on hugging Face Pre training model: generate doccano request JSON format
JVM (19) -- bytecode and class loading (4) -- talk about class loader again
5. 数据访问 - EntityFramework集成
app clear data源码追踪
batch size设置技巧
5. Data access - entityframework integration
《4》 Form
Is the human body sensor easy to use? How to use it? Which do you buy between aqara green rice and Xiaomi
Design, configuration and points for attention of network arbitrary source multicast (ASM) simulation using OPNET
做自媒体,有哪些免费下载视频剪辑素材的网站?
Paper reading [open book video captioning with retrieve copy generate network]
The navigation bar changes colors according to the route