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

第一步: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.勾上。


小Q截图-20180605222502.png

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


小Q截图-20180605222740.png

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容