Spring Boot Gradle plugin bootRun task not recogni

2019-07-29 09:02发布

I have a Backbone app generated with Yeoman. Using the Spring Boot Gradle plugin along with the bootRun task to run the app, when I make changes to my JS source and run Grunt to recompile/minify my source into the dist directory, those changes aren't reflected in the currently running bootRun task.

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"
}

Here's my customer resource handlers for mapping the "dist" directory.

@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);
    }

2条回答
唯我独甜
2楼-- · 2019-07-29 09:15

I created a Yeoman plugin that does exactly the same thing, but with Maven.

We have a Spring Boot backend, built with Maven, which works great with an AngularJS frontend, built with Grunt.

You can find this Yeoman generator here: https://github.com/jhipster/generator-jhipster

查看更多
【Aperson】
3楼-- · 2019-07-29 09:22

I got your app to run, and verified that resources served from src/main/resources can be reloaded, but until today only if I use Maven (here's an issue about that). The github issue is fine by me if you want to discuss further.

查看更多
登录 后发表回答