2015-03-13 232 views
2

我想获得一个简单的Spring-Boot应用程序与Spring加载和Gradle一起工作没有任何成功。我曾尝试以下:弹簧加载和Gradle弹簧启动工作

  1. 使用Spring的引导与​​任务只需重新加载静态资源只是在浏览器中一个简单的F5罚款

  2. 如果我再次使用​​,并通过改变类文本编辑器和使用compileJava它不工作。

  3. 如果我运行它IntelliJ Application在现有控制器中进行更改并使用IntelliJ make它只适用于现有方法。犯规更新新的方法,签名等

  4. 使用的IntelliJ与VM参数的变化:

    -javaagent:C:\ Users \用户为myuser \ .m2目录\库\组织\ springframework的\弹簧式\ 1.2.1。 RELEASE \ springloaded-1.2.1.RELEASE.jar -noverify

还是什么都没做。

理想情况下,我想通过使用摇篮执行过程只 - 所以我IDE独立

请看看GitHub的项目,所以你可以看到我的示例代码: Sample Project

只需执行任何更改DemoController

回答

2

似乎诀窍是使用任务build bootRun而不是简单的'bootRun`。

这是一个摇篮建立文件还使用增量编译手表插件时,Java类改变:

buildscript { 
    ext { 
     springBootVersion = '1.2.2.RELEASE' 
     springLoadedVersion = "1.2.1.RELEASE" 
    } 
    repositories { 
     mavenCentral() 
     mavenLocal() 
     jcenter() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
     classpath("org.springframework:springloaded:${springLoadedVersion}") 
     classpath 'com.bluepapa32:gradle-watch-plugin:0.1.5' 
    } 
} 

repositories { 
    mavenCentral() 
    mavenLocal() 
    jcenter() 
} 

apply plugin: "java" 
apply plugin: "spring-boot" 
apply plugin: 'idea' 
apply plugin: 'application' 
apply plugin: 'com.bluepapa32.watch' 


mainClassName = "com.example.my.Application" 

dependencies { 
    compile("org.springframework.boot:spring-boot-starter-web") 
    runtime("org.hsqldb:hsqldb") 
} 

task wrapper(type: Wrapper) { gradleVersion = '2.3' } 

idea { 
    module { 
     inheritOutputDirs = false 
     outputDir = new File("$buildDir/classes/main/") 
    } 
} 

compileJava { 
    //enable compilation in a separate daemon process 
    options.fork = true 
    //enable incremental compilation 
    options.incremental = true 
} 

watch { 
    java { 
     files files('src/main/java') 
     tasks 'compileJava' 
    } 
}