安装lombok插件:File-settings
具体步骤如下图:1
2、找到Plugins 然后在搜索栏里搜索lombok 点击下放的Search in repositories
3、选中lombok Plugin 》》右边选择Install 进行安装
下面是配置lombok
添加lombok的maven的pom.xml依赖:
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.18</version> <scope>provided</scope> </dependency>
示例代码Book.java
package com.ssz.entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class Book { private int id; private String name; private double price; }
然后按快捷键alt+Ins键可看到自动生成了get set toString()等等方法 如下图: