一、Optimizing Dependencies
(1) You should create a property called AAA.BBB.CCC.version to share the version if some dependency versons are the same. For example,Both thehibernate-annotations andhibernate-commons-annotations are components of the same project released by JBoss, and so when there is a new project release, both of these dependencies will change.So the versions of hibernate-annotations and hibernate-commons-annotations should the same.
<project>
...
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.3.0.ga</version>
</dependency>
</dependencies>
...
It shoule be:
<project>
...
<properties>
<hibernate.annotations.version>3.3.0.ga</hibernate.annotations.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>${hibernate.annotations.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>${hibernate.annotations.version}</version>
</dependency>
</dependencies>
...
(2) Pull-up common dependencies to dependencyManagement(parent pom)
If more than one project depends on a specific dependency, you can list the dependency in dependencyManagement. The parent POM can contain a version and a set of exclusions; all the child POM needs to do to reference this dependency is use the groupId and artifactId. Child projects can omit the version and exclusions if the dependency is listed in dependencyManagement.
(3) Use built-in projectversion andgroupId for sibling projects
Use ${project.version}and${project.groupId} when referring to a sibling project. Sibling projects almost always share the samegroupId, and they almost always share the same release version. Using${project.version} will help you avoid the sibling version mismatch problem discussed previously.
如果是兄弟依赖,这样的情况要通过${project.version},${project.groupId}引用父类的的相关信息