Lombok安装使用
1.在Intellij IDEA中安装lombok插件
安装完重启IDEA
2.去设置,这个地方勾上:
3.加依赖
Maven配置:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>
gradle配置:
compileOnly 'org.projectlombok:lombok:1.18.4'
刷新项目就可以了;
以Maven为例:
4.使用
package com.example.entity;
import lombok.Getter;
import lombok.Setter;
/**
* @version 1.0
* @ClassName easyBuyLombok
* @Description todo
* @Author 74981
* @Date 2019/1/15 16:41
*/
public class EasyBuyLombok {
@[email protected]
private String gradeName;
}
非常简洁;
引用:
package com.example.controller;
import com.example.entity.EasyBuyLombok;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @version 1.0
* @ClassName HwController
* @Description todo
* @Author 74981
* @Date 2018/12/18 15:45
*/
@RestController
public class HwController {
@GetMapping("hello")
public String test(){
EasyBuyLombok easy = new EasyBuyLombok();
easy.setGradeName("newName");
System.out.println(easy.getGradeName());
return "Hello YingTaoZi!";
}
}