1
这是一个父POM文件的一部分:为什么在子POM中不需要版本号?
<properties>
<hibernate.annotations.version>3.3.0.ga</hibernate.annotations.version>
<hsqldb.version>1.8.0.7</hsqldb.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.0.7</version>
</dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>${hibernate.annotations.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>${hibernate.annotations.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
儿童POM,我有两个问题: 1)为什么是没有必要指定休眠的版本号? 2)另外,由于hibernate已经在父POM中指定为依赖项,为什么有必要将它包含在子POM中?
感谢您的解释。
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.mavenbook.optimize</groupId>
<artifactId>simple-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>simple-model</artifactId>
<packaging>jar</packaging>
<name>Chapter 8 Simple Object Model</name>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
</dependency>
</dependencies>
</project>
这两个问题都可以通过对'xxxManagement'进行一些研究来回答。这就是它的工作原理。父母管理有关依赖关系的详细信息,为孩子提供**选项**以使用该依赖关系。如果孩子不需要它,那么它没有在它的pom中指定它。如果确实需要它,那么它指定它。细节由父母照顾。 – 2014-09-05 04:23:38
查看[依赖机制介绍](http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html)。显示一些信息用例 – 2014-09-05 05:04:24