springboot使用lombok省略set和get方法

更多文章欢迎访问个人博客 www.herobin.top

使用lombok省略setget方法

首先在pom中加入lombok依赖包

pom.xml

<dependency>
   <groupId>org.projectlombok</groupId>
   <artifactId>lombok</artifactId>
</dependency>

第二步要在preferences里的plugins中安装lombok插件

springboot使用lombok省略set和get方法

这样就可以用过lombok的@Data注解省略set和get方法了

ProductCategory.java

/**
 * 类目
 * Created by binzhang on 18/7/21.
 */
@Entity
//用这个注解才能实现动态更新(update_time的更新)
@DynamicUpdate
@Data
public class ProductCategory {
    @Id
    @GeneratedValue
    private Integer categoryId;

    // 类目名字
    private String categoryName;

    // 类目编号
    private Integer categoryType;

    private Date createTime;

    private Date updateTime;

    @Override
    public String toString() {
        return "ProductCategory{" +
                "categoryId=" + categoryId +
                ", categoryName='" + categoryName + '\'' +
                ", categoryType=" + categoryType +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}

相关文章:

  • 2021-09-05
  • 2021-11-02
  • 2021-07-01
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-03
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
  • 2021-07-25
  • 2021-12-25
相关资源
相似解决方案