Spring Maven-多模块应用程序-干净安装问题 我有一个多模块应用程序, 我需要从父模块导入一些类(它们对于所有模块都类似) 因此,根据intellij的提示,我对父模块建立了依赖关系 (这是我的第一个多模块应用)

Spring Maven-多模块应用程序-干净安装问题 我有一个多模块应用程序, 我需要从父模块导入一些类(它们对于所有模块都类似) 因此,根据intellij的提示,我对父模块建立了依赖关系 (这是我的第一个多模块应用),spring,maven,multi-module,Spring,Maven,Multi Module,问题是当我这样做时 mvn clean install -Dmaven.test.skip=true 我的生成失败。 似乎maven正在从依赖关系在线寻找我的父项目,显然它不存在,它应该在本地寻找。。。我想 实际上,应用程序可以构建和运行,但我不能制作一个包,我不能安装它 我如何解决它? 下面是一些代码: 父级的pom.xml: <parent> <groupId>org.springframework.boot</groupId>

问题是当我这样做时

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>

org.springframework.boot
spring启动程序父级
2.4.3
eu.mrndesign.matned
父母亲
1.0-快照
../信用
../client
../产品
父母亲
描述
聚甲醛
...
org.springframework.boot
springbootmaven插件
${project.parent.version}
其中一个孩子是波姆(他们3岁,看起来几乎一样):

4.0.0
eu.mrndesign.matned
父母亲
1.0-快照
eu.mrndesign.matned
父母亲
1.0-快照
../parent
产品
产品
用于创建信用申请的产品模块
11
以下是清洁安装时的信息:

[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] 
[INFO]-----------------------------------
[信息]建筑信贷1.0-快照[2/4]
[信息]------------------------------------[jar]---------------------------------
[信息]------------------------------------------------------------------------
[信息]父1.0-SNAPSHOT的反应器摘要:
[信息]
[信息]父母。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。成功[0.857秒]
[信息]信用。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。故障[0.133秒]
[信息]客户。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。跳过
[信息]产品。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。跳过
[信息]------------------------------------------------------------------------
[信息]生成失败
[信息]------------------------------------------------------------------------
[信息]总时间:1.237秒
[信息]完成时间:2021-04-09T03:53:09+02:00
[信息]------------------------------------------------------------------------
[错误]无法对项目信用执行目标:无法解析项目eu的依赖项。mrndesign.matned:credit:jar:1.0-SNAPSHOT:在中找不到eu.mrndesign.matned:parent:jar:1.0-SNAPSHOThttps://repo.spring.io/release 缓存在本地存储库中,在spring版本的更新间隔结束或强制更新之前,不会重新尝试解析->[帮助1]
[错误]

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

<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>
4.0.0
eu.mrndesign.matned
父母亲
1.0-快照
../parent
产品
产品
用于创建信用申请的产品模块
11

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


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

但如果没有它,我无法使用来自父级的类,不是吗?如果您想使用其他模块,可以直接将这些模块添加到依赖项中。如果要使用所有可用的类,则无需将其拆分为多个模块。当您有多模块项目时,父pom将具有类型为
pom
packaging
。这意味着它不会生成任何工件,因此不能将其用作依赖项。有很多方法可以通过使用插件等来解决这个问题,但是一个通用的maven方法是在父项目中没有任何代码,应该使用它来定义模块、依赖项管理、公共依赖项和插件配置等。谢谢Setu,你是对的。我做了另一个模块,把课程搬到了那里。现在它工作得很好谢谢,这就是我想听到的:)现在它工作得很好:)
<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>