lombok使用
作者:互联网
- 添加lombok依赖
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
-
idea安装lombok插件
社区版本自带
-
编写实体类
package com.hua;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class Persion {
private String gender;
private String name;
private int age;
}
package com.hua;
public class LombokTest {
public static void main(String[] args) {
Persion persion = new Persion();
persion.setAge(23);
persion.setName("sss");
persion.setGender("男");
System.out.println(persion);
}
}
就可以看到使用注解的效果了
- 常用注解
@Data
@ToString
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
标签:String,使用,private,Getter,Persion,persion,lombok 来源: https://www.cnblogs.com/huameixiao/p/14944088.html