스프링을 사용하다보면 spring-context, spring-web, spring-tx 등등 각각의 라이브러리에 버전을 기재해서 pom.xml을 작성합니다. 이렇게 하다 보면 서로 다른 버전의 spring framework 라이브러리가 include될 수가 있습니다.
따라서 아래와 같이 maven에 spring bom(bill of materials)를 import하면 각기 다른 spring framework가 include되는 것을 방지할 수 있습니다.
또한, 필요한 spring framework 라이브러리 마다 별도의 버전을 기재할 필요가 없습니다.
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 yourdependencyManagement
section to ensure that all spring dependencies (both direct and transitive) are at the same version.
1
2
3
4
5
6
7
8
9
10
11
|
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
|
cs |
An added benefit of using the BOM is that you no longer need to specify the <version>
attribute when depending on Spring Framework artifacts:
1
2
3
4
5
6
7
8
9
10
|
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependencies>
|
cs |
'Programming > Java' 카테고리의 다른 글
스프링 ContentNegotiatingViewResolver (0) | 2014.06.04 |
---|---|
slf4j api 사용 방법 (0) | 2014.06.04 |
httpclient에서 post로 전달되는 값이 인코딩되지 않게하는 방법 (0) | 2009.08.26 |