12.开发小技巧-Lombok
作者:互联网
1.导入依赖
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> idea中搜索安装lombok插件
===============================简化JavaBean开发=================================== @NoArgsConstructor//无参构造 //@AllArgsConstructor //有参构造 @Data//get set方法 @ToString//tostring方法 @EqualsAndHashCode//equals和hashcode方法 public class User { private String name; private Integer age; private Pet pet; public User(String name,Integer age){ this.name = name; this.age = age; } } ================================简化日志开发=================================== @Slf4j//日志注解 很方便 直接就可以使用 @RestController public class HelloController { @RequestMapping("/hello") public String handle01(@RequestParam("name") String name){ log.info("请求进来了...."); return "Hello, Spring Boot 2!"+"你好:"+name; } }
标签:12,String,age,private,name,User,Lombok,public,技巧 来源: https://www.cnblogs.com/dzs894330350/p/16654122.html