[SpringBoot2]Lombok

  • 引入依赖
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
  • idea中搜索安装lombok插件

[SpringBoot2]Lombok

[SpringBoot2]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;
    }
}
上一篇:Invalid prop: type check failed for prop “span“. Expected Number with value 8, got String with value


下一篇:js实现点击<li>标签弹出其索引值