springboot项目开发,热部署让我们不用修改代码之后,反复关闭应用,重启应用。提高开发效率。但是配置热部署,需要注意以下几个方面。
1、依赖设置:pom.xml文件中加入spring-boot-devtools依赖。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
2、maven插件设置:需要在spring-boot-maven-plugin插件中配置参数
<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>
3、编译设置:File->Settings->Build,Execution,Deployment->Compiler:选中 Build project automatically
4、运行设置:ctrl+shift+a 调起搜索,输入registry,点击第一项,打开Registry编辑框,找到compiler.automake.allow.when.
app.running
选中compiler.automake.allow.when.app.running复选框。
以上四步,可以解决设置热部署,以及设置了热部署不生效的问题。
另外,页面的热部署,可以通过前端模板类型来设置,如果使用springboot自带的渲染模板thymeleaf,设置方式是在application.yml配置文件中加入如下配置:
spring:
thymeleaf:
cache: false