找不到Maven多模块依赖性

时间:2018-11-14 14:32:50

标签: java maven pom.xml

我遇到了一个奇怪的错误,我似乎无法解释。

我有一个多模块Maven项目,其中构建了一个模块来测试其他两个模块之间的集成。

几乎是这样的:

root
|
+--dispatcher
|
+--worker
|
+--tester

如果我使用IntelliJ运行测试器,一切都很好,但是通过maven运行它失败。 它失败是因为找不到特定的程序包,而不是因为找不到工件。

我尝试创建一个新项目来测试模块依赖项背后的概念,它似乎可以工作,但是我似乎找不到原因。

这些是pom文件:

父母:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://maven.apache.org/POM/4.0.0"
  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>se.group</groupId>
  <artifactId>parentid</artifactId>
  <version>0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <description>Parent project for all maven modules.</description>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/>
  </parent>

  <modules>
    <module>worker</module>
    <module>dispatcher</module>
    <module>service-testing</module>
  </modules>
...
</project>

调度程序:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://maven.apache.org/POM/4.0.0"
  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>dispatcher</artifactId>
  <version>0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>dispatcher</name>

  <parent>
    <groupId>se.group</groupId>
    <artifactId>parentid</artifactId>
    <version>0.1-SNAPSHOT</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <project.version>${project.version}</project.version>
  </properties>

  <scm>
    <developerConnection>
      scm:git:https://ghe.com/dispatcher.git
    </developerConnection>
    <connection>scm:git:https://ghe.com/dispatcher.git
    </connection>
    <url>https://ghe.com/dispatcher</url>
    <tag>HEAD</tag>
  </scm>

  <distributionManagement>
    <repository>
      <id>releases</id>
      <url>http://nexus.net/repository/maven-releases</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <url>http://nexus.net/repository/maven-snapshots</url>
    </snapshotRepository>
  </distributionManagement>
...
</project>

测试人员:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://maven.apache.org/POM/4.0.0"
  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>systemtest</artifactId>
  <version>0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>systemtest</name>

  <parent>
    <groupId>se.group</groupId>
    <artifactId>parentid</artifactId>
    <version>0.1-SNAPSHOT</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <project.version>${project.version}</project.version>
  </properties>

  <scm>
    <developerConnection>
      scm:git:https://ghe.com/dispatcher.git
    </developerConnection>
    <connection>scm:git:https://ghe.com/dispatcher.git
    </connection>
    <url>https://ghe.com/dispatcher</url>
    <tag>HEAD</tag>
  </scm>

  <distributionManagement>
    <repository>
      <id>releases</id>
      <url>http://nexus.net/repository/maven-releases</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <url>http://nexus.net/repository/maven-snapshots</url>
    </snapshotRepository>
  </distributionManagement>
  <dependencies>
    <dependency>
      <groupId>se.group</groupId>
      <artifactId>dispatcher</artifactId>
      <version>0.1-SNAPSHOT</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
...
</project>

这应该正确吗?

好吧,我觉得这有点奇怪。 如果我运行mvn clean install会中断,但是如果我运行mvn clean package install

似乎可行

0 个答案:

没有答案