我正在使用带有Gradle插件的Spring Boot 1.3.2。在我的多部分项目中,HTML / JS / CSS文件的热交换/重新加载不起作用。
/resources |-wro.groovy |-application.yml |-/templates/(all *.html files and index.html) |-/static/ |-/js/ |-/css/
application.yml
server: port: 8080 spring: thymeleaf: cache: false prefix: classpath:/templates/ suffix: .html enabled: true encoding: UTF-8 mode: HTML5
在te projet中也使用了:wro4j,thymeleaf,AngularJS
部分 gradle.build
buildscript { ext { springBootVersion = '1.3.2.RELEASE' } repositories { maven { url "https://ourartifactoryUrl/plugins-release" credentials { // artifactory log and pass } } } dependencies { classpath group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: springBootVersion classpath group: 'io.spring.gradle', name: 'dependency-management-plugin', version: '0.5.2.RELEASE' classpath group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.1.+' classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7' } } apply plugin: 'spring-boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'com.jfrog.artifactory' apply plugin: 'idea' apply plugin: 'application' apply plugin: 'propdeps' apply plugin: 'propdeps-maven' apply plugin: 'propdeps-idea' apply plugin: 'propdeps-eclipse' ... dependencies { compile('org.springframework.boot:spring-boot-starter-web') compile("org.springframework.boot:spring-boot-starter-thymeleaf") compile("org.springframework.boot:spring-boot-starter-jetty") compile("org.springframework.boot:spring-boot-starter-actuator") compile("org.springframework.boot:spring-boot-starter-redis") compile("org.springframework.boot:spring-boot-devtools") }
使用以下命令执行项目: gradle :web-admin:bootRun
gradle :web-admin:bootRun
更新/回答:
在上网冲浪并阅读Spring-boot文档后,我发现了一个窍门。因此,在使用devtools时出现spring-boot-gradle- plugin问题,我只需要在 gradle.build 文件中添加几行:
devtools
spring-boot-gradle- plugin
// Used by 'Spring Boot Gradle Plugin' in combination with 'Devtools' makes HTML/JS/CSS reloadable. bootRun { addResources = true }
在上网冲浪并阅读Spring-boot文档后,我发现了一个窍门。结果,在将devtools与spring-boot-gradle- plugin一起使用时出现问题,我只需要在gradle.build文件中添加几行: