Dependency Management 태그는 종속성 버전 정보를 한데 모으는데 사용하는 태그입니다. 예를 들어 서로 다른 두 모듈이 공통으로 사용하는 라이브러리가 있다면, 공통된 종속성에 대한 정보를 Dependency Management에 넣으면 하위 모듈 pom.xml에서는 버전 정보를 기입하지 않아도 됩니다.
2. 사용 예시
각 각의 모듈 Project A와 Project B가 있다고 가정하겠습니다.
<!-- before Project A --><project>
...
<dependencies><dependency><groupId>group-a</groupId><artifactId>artifact-a</artifactId><version>1.0</version><exclusions><exclusion><groupId>group-c</groupId><artifactId>excluded-artifact</artifactId></exclusion></exclusions></dependency><dependency><groupId>group-a</groupId><artifactId>artifact-b</artifactId><version>1.0</version><type>bar</type><scope>runtime</scope></dependency></dependencies></project>
<!-- before Project B --><project>
...
<dependencies><dependency><groupId>group-c</groupId><artifactId>artifact-b</artifactId><version>1.0</version><type>war</type><scope>runtime</scope></dependency><dependency><groupId>group-a</groupId><artifactId>artifact-b</artifactId><version>1.0</version><type>bar</type><scope>runtime</scope></dependency></dependencies></project>
이 때 두 모듈이 의존하는 라이브러리에 대한 버전 정보를 dependencyManagement 태그를 사용해서 상위 pom.xml에 한 번에 기입할 수 있습니다.
<!-- parent pom.xml --><project>
...
<dependencyManagement><dependencies><!-- for Project A --><dependency><groupId>group-a</groupId><artifactId>artifact-a</artifactId><version>1.0</version><exclusions><exclusion><groupId>group-c</groupId><artifactId>excluded-artifact</artifactId></exclusion></exclusions></dependency><!-- for Project B --><dependency><groupId>group-c</groupId><artifactId>artifact-b</artifactId><version>1.0</version><type>war</type><scope>runtime</scope></dependency><!-- for Project A, B --><dependency><groupId>group-a</groupId><artifactId>artifact-b</artifactId><version>1.0</version><type>bar</type><scope>runtime</scope></dependency></dependencies></dependencyManagement></project>
그러면 각 각의 A, B 모듈에서는 참조하는 라이브러리에 대한 버전을 기입하지 않아도 됩니다.
<!-- after Project A --><project>
...
<dependencies><dependency><groupId>group-a</groupId><artifactId>artifact-a</artifactId></dependency><dependency><groupId>group-a</groupId><artifactId>artifact-b</artifactId><!-- This is not a jar dependency, so we must specify type. --><type>bar</type></dependency></dependencies></project>
<!-- after Project B --><project>
...
<dependencies><dependency><groupId>group-c</groupId><artifactId>artifact-b</artifactId><!-- This is not a jar dependency, so we must specify type. --><type>war</type></dependency><dependency><groupId>group-a</groupId><artifactId>artifact-b</artifactId><!-- This is not a jar dependency, so we must specify type. --><type>bar</type></dependency></dependencies></project>