Spi*_*der 7 intellij-idea gradle thymeleaf spring-boot
我创建了一个使用Thymeleaf的Spring Boot Gradle项目.我的IDE是IntelliJ.我在根文件夹中创建了一个application.properties:
spring.resources.cache-period=0
spring.thymeleaf.cache=false
spring.thymeleaf.mode=LEGACYHTML5
Run Code Online (Sandbox Code Playgroud)
但不知何故,它仍然没有自动重装.我必须先点击"制作项目"按钮.我有另一个项目,具有相同的配置(不确定IntelliJ设置)奇怪的是,确实可以刷新.
正在读取我的application.properties,因为我可以使用@Value注释来提取自定义属性.
作为参考,我的build.gradle
buildscript {
ext {
springBootVersion = '1.3.1.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.springframework:springloaded:1.2.5.RELEASE")
}
}
apply plugin: 'spring-boot'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
targetCompatibility = 1.8
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
}
}
jar {
baseName = 'earthalive'
version = ""
}
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('net.sourceforge.nekohtml:nekohtml:1.9.22')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.9'
}
Run Code Online (Sandbox Code Playgroud)
想法?
src/main/resources使用bootRun时,Spring Boot Gradle插件不再直接添加到类路径中.如果您想要实时的就地编辑,我们建议您使用Devtools.如果要还原Spring Boot 1.2,可以在gradle构建中设置addResources属性.行为.
无论你是否使用spring-boot-devtools,Thymeleaf都依赖于src/main/resources被添加到类路径中.幸运的是,spring-boot-devtools确实有一个选项可以再次打开它来恢复启动1.2行为.
添加到build.gradle:
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle-plugin.html
bootRun {
addResources = true
}
Run Code Online (Sandbox Code Playgroud)
个人意见:在我看来,像Spring-loaded最终会被弃用,而不是spring-boot-devtools.动态hotswapping在Spring中似乎是一个复杂的事情,我认为Spring团队决定在devtools使用的快速重新加载的基础上工作.
| 归档时间: |
|
| 查看次数: |
6636 次 |
| 最近记录: |