只需在pom文件中添加依赖即可
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 不能被其他模块继承,如果有多个子模块可以删除 -->
</dependency>
如果不生效,检查项目是否自动编译,打开上方工具栏Project-->Build Automatically,如果没有选中就勾上就行