1.在pom.xml文件中设置(两小步)
1.1:在<dependeccys>标签中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>false</optional>
<scope>runtime</scope>
</dependency>
1.2:在<build>标签中的<plugins>标签中添加
<plugin>
<!--热部署配置-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--fork:如果没有该项配置,整个devtools不会起作用-->
<fork>true</fork>
</configuration>
</plugin>
2.在application.properties
#热部署生效
spring.devtools.restart.enabled=true
#设置重启的目录,添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
3.设置
找到
file--->settings--->Build,Execution,Deployment--->Compiler
勾选
Build project automatically
4.设置(Registry)
按ctrl+shift+A或者(ctrl+shift+alt+/)
输入Registry
找到Registry点击进去
勾选:compiler.automake.allow.when.app.running
5.完成热部署
图解
1.修改pom.xml
2.修改application.config
3.设置:File–>Settings–>Compiler勾选Build project automatically
4.搜索按下(shift+ctrl+a或者shift+ctrl+alt+/)输入Registry
勾选compiler.automake.allow.when.app.running
5.完成热部署