浅谈Spring解决jar包依赖的bom

这篇文章主要介绍了浅谈Spring解决jar包依赖的bom,具有一定借鉴价值,需要的朋友可以参考下

名词解释:

BOM(bill of materials):材料清单,用于解决jar包依赖的好方法。

Spring IO Platform

缘起:Spring起初只专注ioc和aop,现在已发展成一个庞大体系。比如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.”
举例如下:

 <dependencies><dependency><groupId>org.springframeworkgroupId>dependency>dependencies>
  • 1
  • 2
  • 3
  • 4
  • 5

Spring IO Platform只是一个pom文件,记录了spring与其他开源项目对应的版本。省去了版本号,也就省去了处理依赖时的问题,因为Spring IO Platform中有最优的版本配置。

Spring相关的BOM

当然SpringSource为了解决这些Jar冲突,推出了各种BOM,当然最著名的就是spring platform io bom,其中最核心的三个是:spring-framework-bom、spring-boot-dependencies、platform-bom。

对于Spring工程来说,直接在pom.xml文件中添加如下配置代码,即可免去管理版本冲突的难题。

 <dependencyManagement><dependencies><dependency><groupId>org.springframeworkgroupId><artifactId>spring-framework-bomartifactId><version>4.2.0.RELEASEversion><type>pomtype><scope>importscope>dependency><dependency><groupId>org.springframework.bootgroupId><artifactId>spring-boot-dependenciesartifactId><version>1.3.0.M2version><type>pomtype><scope>importscope>dependency><dependency><groupId>io.spring.platformgroupId><artifactId>platform-bomartifactId><version>1.1.3.RELEASEversion><type>pomtype><scope>importscope>dependency>dependencies>dependencyManagement>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

参考文章

Introduction to spring io platform

总结

以上就是本文关于浅谈Spring解决jar包依赖的bom的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站其他相关专题,如有不足之处,欢迎留言指出。感谢朋友们对本站的支持!

以上就是浅谈Spring解决jar包依赖的bom的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » Java