我正在与Gradle一起使用Spring框架。我知道要包含一些Spring依赖项,我可以引用"starters“而无需显式定义版本;版本将由我选择的Spring版本控制,这是Spring插件的版本。示例(省略了不相关的分级代码):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: BOOT_VERSION
classpath group: 'io.spring.gradle', name: 'dependency-management-plugin', version: DEP_MGMT_VERSION
}
}
...
dependencies {
compile 'org.springframework.boot:spring-boot'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
请注意,没有明确的版本为我的应用程序依赖项定义了my版本。
现在,假设我想包含一些Spring和Spring依赖项。例如:
compile 'org.springframework.integration:spring-integration-mqtt:some-version'
compile 'org.springframework.cloud:spring-cloud-netflix-eureka-server:some-other-version'
如何确保用于这些依赖项的版本与其他Spring依赖项兼容?我不能忽略这个版本,所以看起来Gradle插件并没有处理这些依赖关系(也许它只处理那些拥有组org.springframework.boot
的人?)。
换句话说,是否有一种干净、安全的方法来确保我所有的Spring依赖项能够一起工作,比如Spring、Spring等等?
发布于 2018-03-18 02:08:37
使用gradle脚本中的启动程序。
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:2.0.0.RELEASE")
compile ':spring-cloud-starter-config'
compile ':spring-cloud-starter-netflix-eureka-client'
compile ':spring-boot-starter-integration'
}
https://github.com/spring-gradle-plugins/dependency-management-plugin/blob/master/README.md
对于Spring,添加一个具有兼容云到启动版本的dependencyManagement部分。文档指出哪些项目版本与相应的启动列车(1.4.x、1.5.x、2.x)兼容:
dependencyManagement {
imports {
mavenBom ':spring-cloud-dependencies:Finchley.M8'
}
}
Finchley构建SpringBoot2.0.x并与其协同工作,而不是使用SpringBoot1.5.x。 Dalston和Edgware发布的列车构建在SpringBoot1.5.x上,并且不希望使用SpringBoot2.0.x。 Camden发布列车构建在SpringBoot1.4.x上,但也用1.5.x进行了测试。
http://projects.spring.io/spring-cloud/
https://stackoverflow.com/questions/49305737
复制相似问题