子项目无法从超级POM获取依赖项

问题描述 投票:0回答:2

我有以下情况:diag-parent(超级POM)和diag-domain(子)

超级POM:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>de.dbsystel.udg</groupId>
        <artifactId>udg-super-pom</artifactId>
        <version>2.0.3</version>
        <relativePath/>
    </parent>

    <groupId>de.db.udg.diagnose.udg-diagnose</groupId>
    <artifactId>diag-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.20.16-SNAPSHOT</version>
    <name>${project.artifactId}</name>

    <modules>
        <module>diag-domain</module>
    </modules>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>de.db.kolt.alice</groupId>
                <artifactId>alice</artifactId>
                <version>2.2.1</version>
                <scope>compile</scope>
            </dependency>

            <dependency>
                <groupId>org.primefaces</groupId>
                <artifactId>primefaces</artifactId>
                <version>7.0</version>
            </dependency>

            <!-- PrimeFaces File Upload utils -->
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.2.1</version>
            </dependency>

            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.6</version>
            </dependency>
...
</dependencies>
    </dependencyManagement>

儿童POM:

    <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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>de.db.udg.diagnose.udg-diagnose</groupId>
    <artifactId>diag-parent</artifactId>
    <version>1.20.16-SNAPSHOT</version>
  </parent>

  <artifactId>diag-domain</artifactId>
  <packaging>jar</packaging>
  <name>${project.artifactId}</name>
...
</project>

编译diag-domain模块结果为:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project diag-domain: Compilation failure: Compilation failure:
[ERROR] /D:/Projekte/FA-DIAGNOSE/UDG-DIAGNOSE/branches/Richface_Migration/impl/diag-domain/src/main/java/de/db/udg/diagnose/udgdiag/domain/base/ToManyAssociationModel.java:[13,28] package org.primefaces.model does not exist

它显然不会从diag-parent中获取any依赖项。甚至我的.m2存储库都是空的。

[C0的有效pom:

diag-domain
maven pom.xml parent-pom
2个回答
0
投票

<!-- ====================================================================== --> <!-- --> <!-- Generated on 2020-01-09T11:13:57 --> <!-- --> <!-- ====================================================================== --> <!-- ====================================================================== --> <!-- --> <!-- Effective POM for project --> <!-- 'de.db.udg.diagnose.udg-diagnose:diag-domain:jar:1.20.16-SNAPSHOT' --> <!-- --> <!-- ====================================================================== --> <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> <groupId>de.db.udg.diagnose.udg-diagnose</groupId> <artifactId>diag-parent</artifactId> <version>1.20.16-SNAPSHOT</version> </parent> <groupId>de.db.udg.diagnose.udg-diagnose</groupId> <artifactId>diag-domain</artifactId> <version>1.20.16-SNAPSHOT</version> <name>diag-domain</name> <description>domain objects</description> <dependencyManagement> <dependencies> ... <dependency> <groupId>org.primefaces</groupId> <artifactId>primefaces</artifactId> <version>7.0</version> <scope>compile</scope> </dependency> ... </dependencyManagement> </dependencies> </project> 中的条目不是依赖项。它们只是依赖性的标准版本。

依赖关系必须位于<dependencyManagement><dependencies>标记outside中。


0
投票

因为您仅使用dependencyManagement,所以不导入依赖关系。您需要在子pom中添加一个部分,然后在其中输入依赖项。

DepenencyManagement仅用于为所有子模块使用标记某些版本的依赖项。

参见:<dependencyManagement>

[当您有一组从公共父项继承的项目时,可以将有关依赖项的所有信息放入公共POM中,并在子POM中具有对工件的更简单引用

© www.soinside.com 2019 - 2024. All rights reserved.