maven多模块依赖编译问题

cygmwpex  于 2021-06-27  发布在  Java
关注(0)|答案(1)|浏览(341)

在使用intellij的多模块项目中,我的maven依赖性遇到了一些问题。
下面是我的maven模块的结构:(1) venus 是根模块(2) architect 是的父模块 architect-com 模块(3) actions-com 是的子模块 actions 模块和 services 是的父模块 actions 模块(4) architect 以及 services 是根模块的直接子模块

- venus
  - architect
    - architect-com
      - src [java classes here]
  - services
    - actions
      - actions-com
         - src [java classes here]

架构师、服务和操作模块没有src文件夹(我删除了它们,因为我认为父模块不需要src文件夹)
下面是模块的pom。
//维纳斯-根模块

<?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>co.shock</groupId>
    <artifactId>venus</artifactId>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>services</module>
        <module>services/actions</module>
        <module>services/actions/actions-com</module>
        <module>architect</module>
        <module>architect/architect-com</module>
    </modules>
    <packaging>pom</packaging>
</project>

//建筑师

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

    <parent>
        <artifactId>venus</artifactId>
        <groupId>co.shock</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <name>architect</name>
    <groupId>co.shock.jupiter</groupId>
    <artifactId>architect</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>architect-com</module>
    </modules>

</project>

//架构师com

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

    <parent>
        <artifactId>architect</artifactId>
        <groupId>co.shock.venus</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <name>Architect - Com</name>
    <groupId>co.shock.venus.architect</groupId>
    <artifactId>architect-com</artifactId>

    <dependencies>
      // SPRING AND HIBERNATE DEPENDENCIES HERE
    </dependencies>
</project>

//服务

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

    <parent>
        <artifactId>venus</artifactId>
        <groupId>co.shock</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <name>Services</name>
    <groupId>co.shock.venus</groupId>
    <artifactId>services</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>actions</module>
    </modules>

</project>

//行动

<?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>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <artifactId>services</artifactId>
        <groupId>co.shock.venus</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <name>Services - Actions</name>
    <groupId>co.shock.venus.services</groupId>
    <artifactId>actions</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>actions-com</module>
    </modules>

</project>

//动作com

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

    <parent>
        <artifactId>actions</artifactId>
        <groupId>co.shock.venus.services</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <name>Services - Actions - Com</name>
    <groupId>co.shock.venus.services.actions</groupId>
    <artifactId>actions-com</artifactId>

    <dependencies>
        <dependency>
            <groupId>co.shock.venus.architect</groupId>
            <artifactId>architect-com</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

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

</project>

这个 actions-com 模块导入 architect-com 如pom上方的de所示。当我编译 actions-com 模块i出现以下错误:

C:\3_projects\venus\services\actions\actions-com>mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< co.shock.venus.services.actions:actions-com >---------
[INFO] Building Services - Actions - Com 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.256 s
[INFO] Finished at: 2020-12-29T21:02:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project actions-com: Could not resolve dependencies for project co.shock
.venus.services.actions:actions-com:jar:1.0-SNAPSHOT: Failed to collect dependencies at co.shock.venus
.architect:architect-com:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for co.shock.venus
.architect:architect-com:jar:1.0-SNAPSHOT: Could not find artifact co.shock:venus:pom:1.0-S
NAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

下面是我的人生之路 .m2 构建architect com的存储库。以下是快照文件夹的内容

C:\Users\user\.m2\repository\co\shock\venus\architect\architect-com\1.0-SNAPSHOT
   - _remote.repositories
   - architect-com-1.0-SNAPSHOT.jar
   - architect-com-1.0-SNAPSHOT.pom
   - maven-metadata-local.xml

我搜索了一整天,但找不到任何解决办法。我想被指向正确的方向。
我做错什么了?

8gsdolmq

8gsdolmq1#

请看错误消息的最后一句话:
Could not find artifact co.shock:venus:pom:1.0-SNAPSHOT services 包含:

<parent>
        <artifactId>venus</artifactId>
        <groupId>co.shock</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

但金星包含:

<groupId>co.shock</groupId>
    <artifactId>jupiter</artifactId> <!-- should be 'venus' -->
    <version>1.0-SNAPSHOT</version>

你只是把行星搞混了

相关问题