Maven多模块依赖项编译问题

埃迪·弗里曼

在使用IntelliJ的多模块项目中,我的maven依赖项出现问题。

以下是我的Maven模块的结构:(1)venus是根模块。(2)architect是模块的父architect-com模块。(3)actions-com是模块的子模块,是actions模块services的父actions模块。(4)architect并且services是root模块的直接子代

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

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

// actions-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模块时,出现以下错误:

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

我整天用Google搜索,但找不到任何解决方案。我想指出正确的方向。

我究竟做错了什么?

杰罗德·布罗泽(Gerold Broser)

查看错误消息的最后一句: 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>

您只是混合了行星。:)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章