eri*_*mon 6 gradle maven spring-boot
在一个Maven项目中,我具有以下标签:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
Gradle的语法是什么?
这是我的build.gradle当前。我认为这需要在构建脚本中添加,也许替代我目前拥有的。如果可能,请解释为什么我需要添加它。我正在尝试将pom.xml转换为gradle。
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE")
}
}
plugins {
id 'org.springframework.boot' version '1.5.9.RELEASE'
id 'java'
}
repositories {
mavenCentral()
}
/*Runtime dependencies*/
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile("io.springfox:springfox-swagger2:2.6.1")
compile("io.springfox:springfox-swagger-ui:2.6.1")
compile('org.springframework.boot:spring-boot-starter')
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-rest")
}
Run Code Online (Sandbox Code Playgroud)
小智 8
Gradle以下父语法等效于什么Maven
apply plugin : "io.spring.dependency-management"
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
在Gradle中,多模块项目中只有父/子关系。您没有像在Maven中那样具有child-> parent定义。
因此,通常您在一个父文件夹中有一个settings.gradle,其中包含对其子级的引用。
像这样(父settings.gradle):
include 'sub-module-1'
include 'sub-module-2
Run Code Online (Sandbox Code Playgroud)
然后,您有两个子文件夹sub-module-1和sub-module-2,它们包含它们自己的build.gradle文件。
但是,回到您的情况,当您仅使用spring-boot插件时,您不需要任何条件。org.springframework.boot插件将配置所有必要的依赖项,因此您只需要添加可选的依赖项即可想。
| 归档时间: |
|
| 查看次数: |
2918 次 |
| 最近记录: |