一、添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
二、使用插件
<build>
<finalName>projectName</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
注:此处如果显示红色,添加一个版本号再刷新一下;如果依旧,删掉本地仓库
respository/org/springreamework/boot/spring-boot-maven-plugin
内的所有jar包,再次刷新;
三、配置idea
1、idea中,Setting -> Build -> Compiler -> Auto…show、Display、Build、Compile independent… 勾选
2、Alt + Ctrl + Shift + /
打开 Registry
3、勾选:compiler.automake.allow.when.app.running
4、重启