当前位置:网站首页>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;
}
}
边栏推荐
- 论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】
- 京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口
- [PM products] what is cognitive load? How to adjust cognitive load reasonably?
- Safe landing practice of software supply chain under salesforce containerized ISV scenario
- 数字化创新驱动指南
- 实现网页内容可编辑
- 1.AVL树:左右旋-bite
- Paper reading [semantic tag enlarged xlnv model for video captioning]
- [reading of the paper] a multi branch hybrid transformer network for channel terminal cell segmentation
- Taobao store release API interface (New), Taobao oauth2.0 store commodity API interface, Taobao commodity release API interface, Taobao commodity launch API interface, a complete set of launch store i
猜你喜欢
[binary tree] binary tree path finding
【js组件】自定义select
English grammar_ Noun possessive
DOM node object + time node comprehensive case
Intelligent annotation scheme of entity recognition based on hugging Face Pre training model: generate doccano request JSON format
利用OPNET进行网络单播(一服务器多客户端)仿真的设计、配置及注意点
Flink SQL realizes reading and writing redis and dynamically generates hset key
Unity让摄像机一直跟随在玩家后上方
5. 数据访问 - EntityFramework集成
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
随机推荐
How can professional people find background music materials when doing we media video clips?
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
Unity让摄像机一直跟随在玩家后上方
Reading the paper [sensor enlarged egocentric video captioning with dynamic modal attention]
拼多多商品详情接口、拼多多商品基本信息、拼多多商品属性接口
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
AIDL 与Service
Mysql database learning (8) -- MySQL content supplement
架构设计的五个核心要素
[paper reading] semi supervised left atrium segmentation with mutual consistency training
sql优化常用技巧及理解
导航栏根据路由变换颜色
漏电继电器JD1-100
Leetcode: maximum number of "balloons"
Cve-2021-3156 vulnerability recurrence notes
Leetcode 1189 maximum number of "balloons" [map] the leetcode road of heroding
[reading of the paper] a multi branch hybrid transformer network for channel terminal cell segmentation
ThinkPHP Association preload with
Pytest testing framework -- data driven
Torch optimizer small parsing