【发布时间】:2014-01-29 14:06:59
【问题描述】:
我有一个使用 Yeoman 生成的 Backbone 应用程序。使用 Spring Boot Gradle 插件和 bootRun 任务来运行应用程序,当我对我的 JS 源进行更改并运行 Grunt 以将我的源重新编译/缩小到 dist 目录时,这些更改不会反映在当前运行的 bootRun 任务中.
build.gradle
buildscript {
repositories {
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M7"
}
}
apply plugin: "java"
apply plugin: "idea"
apply plugin: "spring-boot"
apply plugin: "war"
war {
baseName = "mis-support-client"
version = "1.0.0-SNAPSHOT"
includes = ["dist/**"]
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
testCompile "junit:junit:4.11"
compile ("org.springframework.boot:spring-boot-starter-web:0.5.0.M7") {
exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty:0.5.0.M7"
compile "org.springframework.boot:spring-boot-starter-security:0.5.0.M7"
compile "org.springframework.boot:spring-boot-starter-websocket:0.5.0.M7"
compile "javax.inject:javax.inject:1"
compile "org.codehaus.jackson:jackson-mapper-asl:1.9.12"
compile "org.apache.httpcomponents:httpclient:4.3.1"
compile "commons-io:commons-io:2.4"
}
task wrapper (type: Wrapper) {
gradleVersion = "1.8"
}
这是我用于映射“dist”目录的客户资源处理程序。
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/bower_components/**", "/scripts/**", "/styles/**", "/fonts/**", "/font/**")
.addResourceLocations("/dist/bower_components/", "/dist/scripts/", "/dist/styles/", "/dist/bower_components/bootstrap/fonts/", "/dist/bower_components/font-awesome/font/")
.setCachePeriod(315569126);
}
【问题讨论】:
-
请附上你的 gradle.build
-
Gradle 和 Spring 对生成的资源或用于创建它们的过程一无所知。我相信您应该能够在
src/main/resources/static(等)中编辑静态资源并在正在运行的应用程序中查看这些更改(也许您可以确认?)。 -
我会试试看的。我对 Gradle 和 Boot 仍然很陌生,所以这只是弄清楚事情是如何工作的过程。在我尝试过您的建议后会发布反馈。
-
好的。如果 grunt 在众所周知的位置生成资源,我们可能会为您检测更改(或允许您在 Gradle 中配置它)。如果您可以在 github(或类似网站)上分享一些东西,那么一个完整的、最小的示例项目将是一个有用的起点。
-
我在 Bitbucket bitbucket.org/pgrimard/spring-boot-backbone/overview创建了一个仓库
标签: backbone.js gradle spring-boot