用于解决对 Spring + Spring Data + Spring Security 的依赖关系的 Maven BOM?
Posted
技术标签:
【中文标题】用于解决对 Spring + Spring Data + Spring Security 的依赖关系的 Maven BOM?【英文标题】:Maven BOM for solving dependencies on Spring + Spring Data + Spring Security? 【发布时间】:2016-03-23 19:04:32 【问题描述】:Spring Data Jpa Docs 建议使用 Maven BOM (bill of materials),原因是:
由于各个 Spring Data 模块的启动日期不同,大多数 其中有不同的主要和次要版本号。最简单的方法 找到兼容的是依靠 Spring Data Release Train BOM 我们附带定义的兼容版本。在一个 Maven 项目中,你会 在 POM 的
<dependencyManagement/>
部分声明此依赖项
提供了对official example 的引用。
我知道了 BOM 和 dependencyManagement
。供应商正式向我们(开发人员)提供经过测试/推荐/支持的兼容性列表。 太棒了!
为了同步移动版本,我需要一些管理以下 BOM 的“超级 BOM”:
org.springframework:spring-framework-bom
org.springframework.data:spring-data-releasetrain
org.springframework.security:spring-security-bom
如何选择兼容的?
是否有适用于所有伞的 SPRING-SUPER-BOM(我的意思是官方或社区支持,因此我通过避免故障排除来节省我的时间,如果发生这种情况并且我发现并解决了问题 - 我有将解决方案返回给社区的选项)?
【问题讨论】:
你检查过the website吗? 【参考方案1】:新功能感谢您向 @jumping_monkey 指出 Spring 平台弃用。
现在你应该转发org.springframework.boot:spring-boot-dependencies。这并不意味着您开始使用 Spring Boot。这只表示你使用的是 Spring Boot 托管的依赖管理!
因此您的构建文件可能如下所示:
apply plugin: 'io.spring.dependency-management'
dependencyManagement
imports
mavenBom "org.springframework.boot:spring-boot-starter-parent:$projSpringBootVersion"
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:$projSpringCloudVersion"
mavenBom "org.springframework.cloud:spring-cloud-gcp-dependencies:$projSpringGcpVersion"
applyMavenExclusions = false
请注意,spring-boot-starter-parent
和 spring-cloud-starter-parent
的版本之间仍然存在不确定性。但没关系。至少它们有助于管理 Hibernate/Jeckson/whatever 的版本!
OLD感谢@M.Deinum指向Spring IO platform
此项目提供各种 Spring 项目及其依赖项的版本。
可以在相应的http://docs.spring.io/platform/docs/ 或https://github.com/spring-io/platform/blob/master/platform-bom/pom.xml 文件中通过查看不同的标签来检查实际的依赖关系:https://github.com/spring-io/platform/tags
使用本地 Git 克隆很容易做到这一点:
$ git clone https://github.com/spring-io/platform.git
$ cd platform/
$ git tag --list
$ git co v1.0.2.RELEASE
$ less platform-bom/pom.xml
但是您没有在这里找到 spring-core
/spring-mvc
/string-data
/spring-security
的依赖项,因为它们在父 pom spring-boot-starter-parent
中,实际上还包括 spring-boot-dependencies
。
spring-boot-dependencies
有版本和依赖于
spring-framework-bom
spring-data-releasetrain
spring-security-bom
spring-integration-bom
因此,如果您的应用非常广泛 - 您可以使用 io.spring.platform:platform-bom
。但如果该列表过于复杂,只需将org.springframework.boot:spring-boot-dependencies
用作dependencyManagement
。
【讨论】:
一个 bom 只给你依赖管理(以及一些插件作为父级)。所以使用哪个实际上并不重要......我建议使用平台一。 我了解对库的依赖项,但想念什么是平台使用。是否有一些插件/实用程序有助于编码或简化构建过程?还是一些IDE?请注意,我只是没有 senior 头衔的普通开发人员,所以问愚蠢的问题... 我建议阅读参考指南,因为它解释了这些事情。 为了后代,答案中的所有链接都是EOL,spring-io/platform已存档。Users of the Platform are encouraged to start using Spring Boot's dependency management directly, either by using spring-boot-starter-parent as their Maven project's parent, or by importing the spring-boot-dependencies bom.
以上是关于用于解决对 Spring + Spring Data + Spring Security 的依赖关系的 Maven BOM?的主要内容,如果未能解决你的问题,请参考以下文章