错误:' dependencies.dependency.version'必须是有效的版本,但是

时间:2014-05-16 00:20:10

标签: maven

我有这个父POM文件(hawaii-banner\pom.xml):

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>base</artifactId>
    <groupId>org.sakaiproject</groupId>    
    <version>2.9.3</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <name>University of Hawaii Banner</name>
  <groupId>edu.hawaii.sakai</groupId>
  <artifactId>hawaii-banner</artifactId>
  <version>${hawaii.banner.version}</version>
  <packaging>pom</packaging>
  <properties>
    <downloadSources>true</downloadSources>
    <downloadJavadocs>true</downloadJavadocs>
    <hawaii.banner.version>2.5.0</hawaii.banner.version>
    <uh-gatech.version>2.5.1</uh-gatech.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.sakaiproject.kernel</groupId>
      <artifactId>sakai-kernel-api</artifactId>
      <version>${sakai.kernel.version}</version>
    </dependency>
    <dependency>
      <groupId>org.sakaiproject.kernel</groupId>
      <artifactId>sakai-kernel-util</artifactId>
      <version>${sakai.kernel.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
  </dependencies>  

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*Test.java</include>
          </includes>

          <!-- Exclude by default the tests that use remote systems. -->
          <excludes>
            <exclude>**/*Test.java</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <modules>
    <module>api</module>
    <module>impl</module>
    <module>integration-test</module>
    <module>pack</module>
    <module>sections-impl</module>
  </modules>

</project>

这个子POM文件(hawaii-banner\api\pom.xml):

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>edu.hawaii.sakai</groupId>
    <artifactId>hawaii-banner</artifactId>
    <version>2.5.0</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <name>University of Hawaii Banner API</name>
  <groupId>edu.hawaii.sakai</groupId>
  <artifactId>hawaii-banner-api</artifactId>
  <version>${hawaii.banner.version}</version>
  <packaging>jar</packaging>
  <properties>
    <deploy.target>shared</deploy.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
    </dependency>
    <dependency>
      <groupId>edu.gatech.sakai</groupId>
      <artifactId>uh-gatech-banner-api</artifactId>
      <version>${uh-gatech.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>

但是我收到了这个错误:

[ERROR]     'dependencies.dependency.version' for edu.gatech.sakai:uh-gatech-banner-api:jar must be a valid version but is '${uh-gatech.version}'. @ edu.hawaii.sakai:hawaii-banner-api:${hawaii.banner.version}, C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\hawaii-banner\api\pom.xml, line 26, column 16

我不明白为什么我会收到此错误,因为在父POM文件中定义了uh-gatech.version,而<version>${uh-gatech.version}</version>曾经是<version>2.5.1</version>,这是有效的

我从与父POM文件相同的目录中运行mvn clean install,但它没有工作。

1 个答案:

答案 0 :(得分:2)

如果maven发出此错误,则表示子模块无法正确识别父级。我发现错误的版本会发生这种情况 你认为你正在定义合适的父母,但你不是。正如@jordan建议的那样,通过消除亲子关系,你可以看到它有效。

您无法将模块的版本定义为您在同一个pom中定义的变量,而maven也不希望这样做。

虽然你认为它是2.5.0,但它不是......

我建议您在项目中查看此关系定义。

我希望这会有所帮助。