Maven - 多模块应用程序 - 全新安装问题

Maven - multi module application - problem with clean install


我有一个多模块应用程序,
我需要从 parent 模块中导入一些 类 (它们对于所有模块都是相似的)
因此,根据 intellij 的提示,我依赖了 parent 模块
(这是我的第一个多模块应用程序)

问题是当我这样做时

mvn clean install -Dmaven.test.skip=true 

我构建失败。
貌似maven正在从网上的依赖中寻找我的parent项目,显然它不存在,应该在本地寻找......我认为

实际上可以构建应用程序,运行,但我无法打包,无法安装...

我该如何解决?
这是一些代码:

pom.xml 对于 parent:

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

其中一个 children 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] 

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

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

父项不能包含代码,因此不能用作依赖项。

将您的 类 放入一个模块中,并将该模块用作其他模块的依赖项。