[SpringBoot2]Lombok
作者:互联网
- 引入依赖
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
- idea中搜索安装lombok插件
===============================简化JavaBean开发===================================
@NoArgsConstructor //无参构造器
//全参构造器
//@AllArgsConstructor
@Data
@ToString
@EqualsAndHashCode
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;
}
}
标签:name,age,private,SpringBoot2,User,Lombok,public,String 来源: https://blog.csdn.net/m0_51955470/article/details/122666730