diff --git a/III. Using Spring Boot/13.2. Gradle.md b/III. Using Spring Boot/13.2. Gradle.md index e69de29..59b2ea6 100644 --- a/III. Using Spring Boot/13.2. Gradle.md +++ b/III. Using Spring Boot/13.2. Gradle.md @@ -0,0 +1,29 @@ +### 13.2. Gradle + +Gradle用户可以直接在它们的`dependencies`节点处导入”starter POMs“。跟Maven不同的是,这里没有用于导入共享配置的"超父"(super parent)。 +```gradle +apply plugin: 'java' + +repositories { jcenter() } +dependencies { + compile("org.springframework.boot:spring-boot-starter-web:1.3.0.BUILD-SNAPSHOT") +} +``` +[spring-boot-gradle-plugin](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#build-tool-plugins-gradle-plugin)插件也是可以使用的,它提供创建可执行jar和从source运行项目的任务。它也添加了一个`ResolutionStrategy`用于让你省略常用依赖的版本号: +```gradle +buildscript { + repositories { jcenter() } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.0.BUILD-SNAPSHOT") + } +} + +apply plugin: 'java' +apply plugin: 'spring-boot' + +repositories { jcenter() } +dependencies { + compile("org.springframework.boot:spring-boot-starter-web") + testCompile("org.springframework.boot:spring-boot-starter-test") +} +```