2015-03-17 16:44:54 +00:00
|
|
|
|
### 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")
|
|
|
|
|
}
|
|
|
|
|
```
|
2015-05-16 02:05:42 +00:00
|
|
|
|
[spring-boot-gradle-plugin](../VIII. Build tool plugins/59. Spring Boot Gradle plugin.md)插件也是可以使用的,它提供创建可执行jar和从source运行项目的任务。它也添加了一个`ResolutionStrategy`用于让你省略常用依赖的版本号:
|
2015-03-17 16:44:54 +00:00
|
|
|
|
```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")
|
|
|
|
|
}
|
|
|
|
|
```
|