diff --git a/IX. ‘How-to’ guides/72.6.2. Configuring Spring Loaded for use with Gradle and IntelliJ.md b/IX. ‘How-to’ guides/72.6.2. Configuring Spring Loaded for use with Gradle and IntelliJ.md index e69de29..c7351c4 100644 --- a/IX. ‘How-to’ guides/72.6.2. Configuring Spring Loaded for use with Gradle and IntelliJ.md +++ b/IX. ‘How-to’ guides/72.6.2. Configuring Spring Loaded for use with Gradle and IntelliJ.md @@ -0,0 +1,28 @@ +### 72.6.2. 使用Gradle和IntelliJ配置Spring Loaded + +如果想将Spring Loaded和Gradle,IntelliJ结合起来,那你需要付出代价。默认情况下,IntelliJ将类编译到一个跟Gradle不同的位置,这会导致Spring Loaded监控失败。 + +为了正确配置IntelliJ,你可以使用`idea` Gradle插件: +```gradle +buildscript { + repositories { jcenter() } + dependencies { + classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.0.BUILD-SNAPSHOT" + classpath 'org.springframework:springloaded:1.2.0.RELEASE' + } +} + +apply plugin: 'idea' + +idea { + module { + inheritOutputDirs = false + outputDir = file("$buildDir/classes/main/") + } +} + +// ... +``` +**注**:IntelliJ必须配置跟命令行Gradle任务相同的Java版本,并且springloaded必须作为一个buildscript依赖被包含进去。 + +此外,你也可以启用Intellij内部的`Make Project Automatically`,这样不管什么时候只要文件被保存都会自动编译你的代码。