一、使用lombok简化代码

lombok提供了很多注解,在编译时候生成java代码,代替了手工编写一些简单的代码,使程序员可以关注更重要的实现。

二、常用注解

以model为例

public class DataDemo {
    private Integer id;
    private String name;
    private Date time;
}

一下是添加不同lombok注解的编译结果示例,编译结果很简单,不需要做什么说明,直接上代码:

@Getter / @Setter

public class GetterSetterDemo {
    private Integer id;
    private String name;
    private Date time;

    public GetterSetterDemo() {  }

    public Integer getId() { return this.id; }

    public String getName() { return this.name; }

    public Date getTime() { return this.time; }

    public void setId(Integer id) { this.id = id; }

    public void setName(String name) { this.name = name; }

    public void setTime(Date time) { this.time = time; }
}
View Code

相关文章:

  • 2022-12-23
  • 2018-07-18
  • 2022-01-06
  • 2021-10-02
  • 2022-03-07
猜你喜欢
  • 2019-07-30
  • 2022-02-08
  • 2021-09-16
  • 2021-08-05
相关资源
相似解决方案