【发布时间】:2017-05-13 12:54:04
【问题描述】:
我有以下依赖的结构:child1->child2。
以及两者的父级,使用${project.version}整合依赖管理中的所有版本。
文件夹结构:
+ parent
+ child1
+ child2
请参阅下面的 poms + 完整示例 here。
当 child2 的版本设置为 1.0-SNAPSHOT 时,一切正常。
当尝试将 just child2 的版本更改为 2.0-SNAPSHOT 时,我收到以下错误:
Failure to find ...:child1:jar:2.0-SNAPSHOT
为什么 maven 尝试查找版本 child1 2.0 而不是 1.0?
家长:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>info.fastpace.issue.unknowversion</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>info.fastpace.issue.unknowversion</groupId>
<artifactId>child1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>info.fastpace.issue.unknowversion</groupId>
<artifactId>child2</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
孩子1:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>child1</artifactId>
<parent>
<groupId>info.fastpace.issue.unknowversion</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
</project>
孩子2:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>child2</artifactId>
<version>2.0-SNAPSHOT</version>
<parent>
<groupId>info.fastpace.issue.unknowversion</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>info.fastpace.issue.unknowversion</groupId>
<artifactId>child1</artifactId>
</dependency>
</dependencies>
</project>
【问题讨论】:
标签: maven jar maven-3 pom.xml parent-pom