解决 idea + springboot + thymeleaf 热部署失效问题

更多干货

转载 https://www.jianshu.com/p/3f60f0f93d5e

第一步:spring.thymeleaf.cache= false

spring:
  application:
    name: server-home
  thymeleaf:
    prefix:classpath:/templates/
    cache:false

第二步:添加maven依赖:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--解决HTML5强校验问题-->
<dependency>
   <groupId>net.sourceforge.nekohtml</groupId>
   <artifactId>nekohtml</artifactId>
   <version>1.9.22</version>
</dependency>
<!--解决thymeleaf模板无法热部署问题-->
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <optional>true</optional> <!--optional设置为true 才为热部署 -->
</dependency>

第三步:修改plugins(这步可以省略)

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!--fork 设置为true -->
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
    </build>

第四步:修改Idea配置
1.打开 Settings –> Build-Execution-Deployment –> Compiler,将 Build project automatically.勾上。

 

 

2.点击 Help –> Find Action..,或使用快捷键 Ctrl+Shift+A来打开 Registry…,将其中的compiler.automake.allow.when.app.running勾上

 

 

第五步:重启项目,然后再修改模板文件或静态资源文件,就可以热部署了


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值