spring bom 解决spring依赖多版本问题

来源:互联网 发布:淘宝假单号哪里买 编辑:程序博客网 时间:2024/05/04 23:06
Maven "Bill Of Materials" Dependency
It is possible to accidentally mix different versions of Spring JARs when using Maven. For example,
you may find that a third-party library, or another Spring project, pulls in a transitive dependency to an
older release. If you forget to explicitly declare a direct dependency yourself, all sorts of unexpected
issues can arise.
To overcome such problems Maven supports the concept of a "bill of materials" (BOM) dependency.
You can import the spring-framework-bom in your dependencyManagement section to ensure
that all spring dependencies (both direct and transitive) are at the same version.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.3.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
An added benefit of using the BOM is that you no longer need to specify the <version> attribute when
depending on Spring Framework artifacts:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>

<dependencies>

上面配置完成后 多个第三方jar依赖的spring版本就可以统一起来,并且 你也不用再申明spring依赖的版本了

1 0
原创粉丝点击