首先,在pom.xml文件里面加入以下的依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
其次,选择FIle → setting
,找到Buid,Execution,Deployment →Compiler
,然后勾选Build project automatically
最后:help → Find Action...
(或使用 Ctrl+shift+A)
然后,输入Registry...
最后勾选compiler.automake.allow.when.app.running
,重启软件
若上面的操作不起作用,可以修改一下pom.xml文件的依赖,其他照旧。
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--热部署启动的关键-->
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>