Spring Boot:在不重新启动服务器的情况下发布Thymeleaf模板

Him*_*dav 2 spring thymeleaf spring-boot

有没有办法在不运行和构建war文件的情况下发布Thymeleaf模板?
这就是我的gradle文件的样子:

apply plugin: 'war'

war {
    baseName = 'bootBlog'
    version =  '0.1.0'
}


repositories {
    mavenLocal()
    mavenCentral()
    maven { url "https://repo.spring.io/libs-release" }
}

configurations {
    providedRuntime
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-starter-data-mongodb")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    testCompile("junit:junit")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
Run Code Online (Sandbox Code Playgroud)

Lel*_*ton 7

thymeleaf的工作方式是通过缓存所有thymeleaf模板作为服务器开机.这就是您没有获得最新模板的原因.要停止高速缓存,还有一个应用程序设置,在被叫application.properties:

 spring.thymeleaf.cache=false
Run Code Online (Sandbox Code Playgroud)

关闭这个选项阻止缓存,支持无需重新启动服务器被刷新的模板.

输入配置后,停止服务器并启动它gradle bootRun.从现在起,你将能够获得最新的thymeleaf模板,而无需刷新.

  • 这对我不起作用:http://stackoverflow.com/questions/34655114/spring-boot-and-thymeleaf-how-to-disable-caching-enable-dynamic-reloading (2认同)