解决jar包依赖:Spring IO platform推出bom
Spring IO Platform
BOM(bill of materials):材料清单,用于解决jar包依赖的好方法
缘起:Spring现在已发展成一个庞大体系。比如security、mvc等。如此一来,不同模块或者与外部进行集成时,依赖处理就需要各自对应版本号。比如,较新spring与较老的quartz,它们集成就会遇到问题,给搭建和升级带来不便。因此Spring IO Platform应运而生,只要项目中引入了它,外部集成时依赖关系无需版本号。官网的原文如下:“when you do declare a dependency on something that’s part of the Platform, you will now be able to omit the version number.”
Spring相关的BOM
当然Spring为了解决这些Jar包的冲突,推出了各种BOM,最著名的就是spring platform io bom,其中最核心的三个是:spring-framework-bom、spring-boot-dependencies、platform-bom。
对于Spring工程来说,直接在pom.xml文件中添加如下配置代码,即可免去管理版本冲突的难题。
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-framework-bom</artifactId> <version>4.2.0.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.3.0.M2</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>io.spring.platform</groupId> <artifactId>platform-bom</artifactId> <version>1.1.3.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
spring-framework-bom只用在一般spring项目集成上就行(如想跟spring)
上图已经介绍了。
Spring IO Platform中维护了哪些依赖,详细请看:
http://docs.spring.io/platform/docs/current/reference/html/appendix-dependency-versions.html