我正在尝试建立一个多模块Maven项目,并且模块间的依存关系显然没有正确设置。
我有:
<modules>
<module>commons</module>
<module>storage</module>
</modules>
在父POM(其具有包装型POM),然后子目录commons/
和storage/
其限定具有相同名称的JAR POMS。
存储取决于Commons。
在主(主)目录中,我运行mvn dependency:tree
并看到:
[INFO] Building system
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] domain:system:pom:1.0-SNAPSHOT
[INFO] \- junit:junit:jar:3.8.1:test
[INFO] ------------------------------------------------------------------------
[INFO] Building commons
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
...correct tree...
[INFO] ------------------------------------------------------------------------
[INFO] Building storage
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
Downloading: http://my.repo/artifactory/repo/domain/commons/1.0-SNAPSHOT/commons-1.0-SNAPSHOT.jar
[INFO] Unable to find resource 'domain:commons:jar:1.0-SNAPSHOT' in repository my.repo (http://my.repo/artifactory/repo)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) domain:commons:jar:1.0-SNAPSHOT
为什么即使反应堆由于成功处理了其依赖关系树而明显看到了对“公共”的依赖关系,却还是失败了?它绝对不应该在网上找到,因为它就在那里...
存储的pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<parent>
<artifactId>system</artifactId>
<groupId>domain</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>domain</groupId>
<artifactId>storage</artifactId>
<name>storage</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- module dependencies -->
<dependency>
<groupId>domain</groupId>
<artifactId>commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- other dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
感谢您的任何建议!
(编辑)
为了澄清,我在这里寻找的是:我不想安装模块X来构建依赖于X的模块Y,因为这两个模块都是从同一父POM引用的。这对我来说很直观,如果我在同一个源代码树中有两件事,则不必安装中间产品来继续构建。希望我的想法在这里有意义。