Spring Boot:热插拔不起作用 [英] Spring Boot: hot swapping does not work
问题描述
我使用Spring Boot 1.3.2和Gradle插件。在我的多部分项目中,对HTML / JS / CSS文件进行热插拔/重新加载不起作用。
/ resources
| -wro.groovy
| -application.yml
| - / templates /(所有* .html文件和index.html)
| - / static /
| - / js /
| - / css /
application.yml
服务器:
端口:8080
弹簧:
thymeleaf:
cache:false
前缀:classpath:/ templates /
后缀:.html
启用:true
编码:UTF-8
模式:HTML5
在projet中也使用:wro4j,thymeleaf,AngularJS
gradle.build的一部分
buildscript {
ext {springBootVersion ='1.3 .2.RELEASE'}
repositories {
maven {
urlhttps:// ourartifactoryUrl / plugins-release
credentials {
// artifactory l og并通过
依赖项{
classpath组:'org.springframework.boot',名称:'spring-boot-gradle-plugin' ,版本:springBootVersion
classpath组:'io.spring.gradle',名称:'dependency-management-plugin',版本:'0.5.2.RELEASE'
classpath组:'org.jfrog。 buildinfo',name:'build-info-extractor-gradle',version:'3.1。+'
classpath'org.springframework.build.gradle:propdeps-plugin:0.0.7'
应用插件:'spring-boot'
应用插件:'io.spring.dependency-management'
apply plugin:'com。 jfrog.artifactory'
apply plugin:'idea'
apply plugin:'application'
apply plugin:'propdeps'
apply plugin:'propdeps-maven'
应用插件:'propdeps-idea'
apply插件:'propdeps-eclipse'
...
依赖关系{
编译( org.springframework.boot:spring-boot-starter-web')
compile(org.springframework.boot:spring-boot-starter-thymeleaf)
compile(org.springframework.boot: )
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
更新/回答: 在网上冲浪并阅读春季启动文档后,我发现了一个窍门。 在互联网上冲浪并阅读春季启动文档后,我发现了一个窍门。结果,在使用devtools和spring-boot-gradle-plugin时出现问题,我只需要在我的gradle.build文件中添加几行内容: I'm using Spring Boot 1.3.2 with gradle plugin. In my multipart project hot swapping/reload for HTML/JS/CSS files does not work. application.yml In te projet also used: wro4j, thymeleaf, AngularJS Part of gradle.build Project executed with: Update/Answer: After some surfing in internet and reading spring-boot docs I found one trick.
Problem in using
After some surfing in internet and reading spring-boot docs I found one trick. Problem in using devtools together with spring-boot-gradle-plugin as a result I simply need to add to my gradle.build file few lines:
这篇关于Spring Boot:热插拔不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
使用 devtools
和 spring-boot-gradle-plugin
结果我只需添加几行 gradle.build 文件即可:
//由'Spring Boot Gradle Plugin'和'Devtools'结合使用,可以重新加载HTML / JS / CSS。
bootRun {
addResources = true
}
//由'Spring Boot Gradle Plugin'和'Devtools'结合使用,可以重新加载HTML / JS / CSS。
bootRun {
addResources = true
}
/resources
|-wro.groovy
|-application.yml
|-/templates/(all *.html files and index.html)
|-/static/
|-/js/
|-/css/
server:
port: 8080
spring:
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
enabled: true
encoding: UTF-8
mode: HTML5
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
devtools
together with spring-boot-gradle-plugin
as a result I simply need to add to my gradle.build file few lines: // Used by 'Spring Boot Gradle Plugin' in combination with 'Devtools' makes HTML/JS/CSS reloadable.
bootRun {
addResources = true
}
// Used by 'Spring Boot Gradle Plugin' in combination with 'Devtools' makes HTML/JS/CSS reloadable.
bootRun {
addResources = true
}