Update 13.2. Gradle.md

master
qibaoguang 2015-03-18 00:44:54 +08:00
parent 877d8c8559
commit 7e7b4e5c88
1 changed files with 29 additions and 0 deletions

View File

@ -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")
}
```