1.Intellij IDEA 下安装lombok
File -> settings -> Plugins -> Browse repositories
搜索 lombok
点install安装
2.添加maven依赖
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.10</version> </dependency>
3.lombok的使用
@Setter
@Getter
@ToString
@EqualsAndHashCode
@Data 相当于上面4个的合集
@Log 省去了在LombokTest中添加 getLogger的如下代码:
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogTest.class.getName());
@Log @RestController public class HelloController { @GetMapping("/hello") public String hello(){ log.info("hello.........."); return "hello"; } }