一、pom.xml配置
1、引入下列依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
- 注意optional的值必须为true,否则热部署将无法生效
2、在plugins标签里配置下列项
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
二、idea打开自动编译
1、*进入设置setting,Build,Execut, Deployment -> Compiler 勾选右侧的Build Project automatically
2、开启项目运行时自动build,打开setting-》搜索registry,然后设置一组快捷键(比如:ctrl + shift + s)
3、ctrl + shift + s打开registry,然后勾选勾选compiler.automake.allow.when.app.running*
4、重启idea,热部署正式生效
spring:
devtools:
remote:
restart:
enabled: true
freemarker:
cache: false