首页 > 解决方案 > Maven 多模块项目尝试从工件获取本地模块的问题

问题描述

我有一段时间没有使用多模块 Maven 项目了,但我正在尝试建立以下项目结构:

在此处输入图像描述

因此,您可以看到我有一组项目是父项目的“辅助自动化工具”。该父级的基本 pom.xml 定义是:

<?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>com.proofofconcept.hat</groupId>
<artifactId>helper-automation-tool</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>helper-automation-tool</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.proofofconcept.hat </groupId>
            <artifactId>helper-automation-tool-dataobjects</artifactId>
            <version>${project.version}</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.proofofconcept.hat </groupId>
            <artifactId>helper-automation-tool-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.proofofconcept.hat</groupId>
            <artifactId>helper-automation-tool-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.proofofconcept.hat</groupId>
            <artifactId>helper-automation-tool-utils</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.proofofconcept.hat</groupId>
            <artifactId>helper-automation-tool-ui</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<modules>
    <module>helper-automation-tool-dataobjects</module>
    <module>helper-automation-tool-utils</module>
    <module>helper-automation-tool-core</module>
    <module>helper-automation-tool-api</module>
    <module>helper-automation-tool-ui</module>
</modules>

有些模块之间应该有依赖关系,我开始尝试使“helper-automation-tool-core”具有“helper-automation-tool-dataobjects”作为依赖项之一,这是它们的配置:

助手自动化工具数据对象

<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>
<parent>
    <artifactId>helper-automation-tool</artifactId>
    <groupId>com.proofofconcept.hat</groupId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<artifactId>helper-automation-tool-dataobjects</artifactId>
<name>helper-automation-tool-dataobjects</name>
<packaging>jar</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

辅助自动化工具核心

<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>

<parent>
    <artifactId>helper-automation-tool</artifactId>
    <groupId>com.proofofconcept.hat</groupId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<artifactId>helper-automation-tool-core</artifactId>
<name>helper-automation-tool-core</name>
<packaging>jar</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>com.proofofconcept.hat</groupId>
        <artifactId>helper-automation-tool-dataobjects</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

</project>

我在核心中有其他依赖项,例如 spring 框架或 jackson mapper,但我将它们排除在外,以免使帖子变大。

当我mvn clean install在 dataobjects 项目上执行时,我得到了成功的构建。

但是当谈到在核心上执行相同的命令时,我得到以下信息:

[ERROR] Failed to execute goal on project helper-automation-tool-core: Could not resolve dependencies for project com.proofofconcept.hat:helper-automation-tool-core:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.proofofconcept.hat:helper-automation-tool-dataobjects:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for com.proofofconcept.hat:helper-automation-tool-dataobjects:jar:1.0-SNAPSHOT: Could not transfer artifact com.proofofconcept.hat:helper-automation-tool:pom:1.0-SNAPSHOT from/to platformServerGADeployement (https://repository.mycompany.com/artifactory/platformserver-ga/): Failed to transfer file: https://repository.mycompany.com/artifactory/platformserver-ga/com/proofofconcept/hat/helper-automation-tool/1.0-SNAPSHOT/helper-automation-tool-1.0-SNAPSHOT.pom. Return code is: 409 , ReasonPhrase:Conflict.

这似乎是一个问题,因为核心正在尝试从工件获取数据对象项目,因为我正在使用一个 settings.xml 文件,该文件已在工件上配置了该项目所需的一些存储库,因为我们需要从下载 spring 和 jackson 依赖项那里。

此外,当我从父项目目录编译整个内容时,我收到数据对象组件不存在的消息(我已经从那里引用了一些类和接口)。

我想知道是否有任何方法或解决方法可以解决这个问题,也许我需要在 settings.xml 或核心的 pom.xml 上进行一些额外的配置来考虑我的本地 repo。

任何帮助将不胜感激。提前致谢。

标签: javamavenmoduleartifactorydependency-management

解决方案


推荐阅读