干货第一篇-SpringBoot配置热部署
修改IDEA设置,允许热部署
- 打开设置:Compiler Build project automatically 勾上
- 按Shift+Ctrl+Alt+/,弹出小框,选择Registry,找到compiler.automake.allow.when.app.running,勾上
修改项目设置
- pom文件添加依赖:
<!--热部署配置:修改代码后不需要进行工程重启-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
- pom文件添加插件:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
- application.yml配置热部署
spring:
devtools:
restart:
enabled: true #设置开启热部署
additional-paths: src/main/java #重启目录
exclude: WEB-INF/**
freemarker:
cache: false #页面不加载缓存,修改即时生效
大功告成
此时你可以修改类,修改配置文件都行,不过可能要等1~3秒的延时时间才能生效。目前测试 Idea 2020.3版本有效。
浙公网安备 33010602011771号