其他分享
首页 > 其他分享> > 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>
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