很多像spring这样的开源项目都包含多个模块,当在maven中添加这些模块作为依赖项时,我应该明确定义每个依赖项还是让传递依赖管理来做它的事情。例如,以下两种情况中的哪一种是最佳实践。
案例 1:包括我想要的最高级别的功能
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
案例 2:将框架的每个部分都包含为显式依赖项
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
.... other dependencies that are transitively resolved by maven
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
最佳实践案例 1 或案例 2 哪个是最佳实践,为什么?