maven-多模块应用程序-干净安装问题

dtcbnfnu  于 2021-07-13  发布在  Java
关注(0)|答案(2)|浏览(312)

我有一个多模块的应用程序,
我需要从父模块导入一些类(它们对于所有模块都是相似的)
因此,根据intellij的提示,我对父模块建立了依赖关系
(这是我的第一个多模块应用程序)
问题是当我这么做的时候

mvn clean install -Dmaven.test.skip=true

我的构建失败了。
似乎maven正在从依赖关系在线上寻找我的父项目,显然它不存在,它应该在本地寻找。。。我想
实际上,应用程序可以构建和运行,但我不能制作一个包,我不能安装它。。。
我该怎么解决?
下面是一些代码:
父级的pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.3</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>eu.mrndesign.matned</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
    <module>../credit</module>
    <module>../client</module>
    <module>../product</module>
</modules>

<name>parent</name>
<description>Description</description>
<packaging>pom</packaging>
        ...
</dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
            </plugin>
        </plugins>
    </build>

</project>

其中一个孩子pom(他们3岁了,看起来几乎一样):

<modelVersion>4.0.0</modelVersion>
<dependencies>
    <dependency>
        <groupId>eu.mrndesign.matned</groupId>
        <artifactId>parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

<parent>
    <groupId>eu.mrndesign.matned</groupId>
    <artifactId>parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../parent</relativePath>
</parent>

<artifactId>product</artifactId>
<name>product</name>
<description>Product module for create credit application</description>
<properties>
    <java.version>11</java.version>
</properties>

以下是清洁安装时的信息:

[INFO] ---------------------< eu.mrndesign.matned:credit >---------------------
[INFO] Building credit 1.0-SNAPSHOT                                       [2/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for parent 1.0-SNAPSHOT:
[INFO] 
[INFO] parent ............................................. SUCCESS [  0.857 s]
[INFO] credit ............................................. FAILURE [  0.133 s]
[INFO] client ............................................. SKIPPED
[INFO] product ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.237 s
[INFO] Finished at: 2021-04-09T03:53:09+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project credit: Could not resolve dependencies for project eu.mrndesign.matned:credit:jar:1.0-SNAPSHOT: Failure to find eu.mrndesign.matned:parent:jar:1.0-SNAPSHOT in https://repo.spring.io/release was cached in the local repository, resolution will not be reattempted until the update interval of spring-releases has elapsed or updates are forced -> [Help 1]
[ERROR]
ycggw6v2

ycggw6v21#

父级不能包含代码,因此不能用作依赖项。
将类放入一个模块中,并将该模块用作其他模块中的依赖项。

tyky79it

tyky79it2#

您需要从子模块中删除父依赖项声明。父标记已经足以指定该模块是父模块的一部分

<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>eu.mrndesign.matned</groupId>
    <artifactId>parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../parent</relativePath>
</parent>

<artifactId>product</artifactId>
<name>product</name>
<description>Product module for create credit application</description>
<properties>
    <java.version>11</java.version>
</properties>

相关问题