其他分享
首页 > 其他分享> > [SpringBoot2]Lombok

[SpringBoot2]Lombok

作者:互联网

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

在这里插入图片描述

在这里插入图片描述

===============================简化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