1、Lombok与Dev-Tools的使用

1.1、Lombok(用于简化JavaBean开发)

1)引入Lombok依赖

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

2)安装Lombok插件

image-20210117161001759

3)使用Lombok

@Data  //Getter、Setter、Equals、HashCode和ToString
@NoArgsConstructor  //无参构造器
@AllArgsConstructor  //全参构造器
public class User {
    private String name;
    private int age;
    private String sex;
}

image-20210117163652734

/**
 * Lombok中Slf4j的使用
 */
@Slf4j
@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String sayHello() {
        log.info("发起hello请求!");
        return "Hello, SuMu!";
    }
}

image-20210117164726470

1.2、Dev-Tools

1)引入devtools依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>

2)只要类路径上的文件更改,使用 Ctrl+F9 快捷键应用程序就会自动重新启动(以IDEA为例,菜单栏Build ===> Build Project具有相同的效果)

Q.E.D.


Keep going, believe in yourself, and never give up.