【问题标题】:How can i exclude a parent dependency "<parent> </parent>" from a .pom file?如何从 .pom 文件中排除父依赖项“<parent> </parent>”?
【发布时间】:2019-03-31 12:15:53
【问题描述】:
I have an issue with a dependency in my pom.xml

<dependency>
    <groupId>com.risk.recoveries.common</groupId>
    <artifactId>disputemanager-client</artifactId>
    <version>1.7</version>
</dependency>

<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>com.risk.recoveries.common</groupId>
        <artifactId>common-parent</artifactId>
        <version>1.4-HELIX-4.0.0-SNAPSHOT</version>
        <relativePath>../../../buildconfig/superpom/pom.xml</relativePath>
    </parent>
  <groupId>com.risk.recoveries.common</groupId>
  <artifactId>disputemanager-client</artifactId>
  <version>1.7</version>
  <name>Dispute Manager Client</name>
  <description>Dispute Manager WSDL client - JAX-WS generated stub</description>
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.8.1</version>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <id>install</id>
                        <goals>
                            <goal>aggregate-jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <linksource>true</linksource>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
                            <extension>true</extension>
                            <wsdlFiles>
                                <wsdlFile>DisputeManager.wsdl</wsdlFile>
                            </wsdlFiles>
                            <!--wsdlLocation>wsdl/DisputeManager.wsdl</wsdlLocation-->
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>target/generated/cxf</directory>
                                    <includes>
                                        <include>**/*.java</include>
                                    </includes>                                 
                                    <followSymlinks>true</followSymlinks>
                                </fileset>
                                <fileset>
                                    <directory>${basedir}/src/main/resources</directory>
                                    <includes>
                                        <include>**/*genlog</include>
                                    </includes>
                                </fileset>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>jaxws/wsimport/java</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.infra</groupId>
            <artifactId>infra-core</artifactId>
        </dependency> 
        <dependency>
            <groupId>com.kernel</groupId>
            <artifactId>uKernelCore</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jmock</groupId>
            <artifactId>jmock-legacy</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
        </dependency>
        <dependency>
            <groupId>com.domain.risk</groupId>
            <artifactId>disputemanager-v3-client</artifactId>
            <version>0.0.5-SNAPSHOT</version>
        </dependency>       
    </dependencies>
</project>

所以在上面的 pom 文件中有这个父标签((common-parent),它不在我的工件正在下载的链接中,所以我收到错误请在下面找到错误,有什么方法可以让我可以从争议管理器客户端工件中排除此父标记(公共父标记)吗?请帮我解决这个问题。

错误:

[错误] 无法在项目 riskactionmsgdDaemon 上执行目标:无法解析项目 com.raptor.risk:riskactionmsgdDaemon:jar:0.0.1-SNAPSHOT 的依赖项:无法在 com.risk.recoveries.common:disputemanager 收集依赖项-client:jar:1.7:无法读取 com.risk.recoveries.common:disputemanager-client:jar:1.7 的工件描述符:找不到工件 com.risk.recoveries.common:common-parent:pom:1.4-HELIX -4.0.0-SNAPSHOT 公开 (https://central.es.com/nexus/content/repositories/public/) -> [帮助 1]

【问题讨论】:

  • 如果不需要依赖项最好从 pom.xml 中删除?

标签: maven spring-boot jenkins


【解决方案1】:

无法排除父依赖项

disputemanager-client 编写 pom.xml 的人严重滥用了&lt;relativePath&gt; 元素。如果父 pom 不是引用它的项目的一部分,则根本不应指定 &lt;relativePath&gt;

首先,您需要验证父 pom.xml 在您的 Nexus 存储库中的任何位置均不可用。请注意,SNAPSHOT 工件(pom、jar 等)通常存储在与已发布工件(版本中没有 -SNAPSHOT 的工件)不同的存储库中。可能是您的~/.m2/settings.xml 文件设置不正确。

如果您在 Nexus 的任何地方都找不到此文件,那么您应该尝试从合作开发者那里获取一份副本。在文件系统中比项目高三级的位置创建buildconfig/superpom 目录(以便relativePath 解析)并将父 pom.xml(由共同开发人员提供)放在那里。

如果没有此文件的副本,您会发现很难继续进行,因为其中似乎已经指定了许多依赖项的版本信息。请注意,许多 disputemanager-client 依赖项没有 &lt;version&gt;...&lt;/version&gt; 元素?这是因为这些版本已经在缺少的父 pom.xml 中指定(甚至是父级的父级)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 2018-04-12
    • 2021-02-27
    • 1970-01-01
    • 1970-01-01
    • 2018-03-02
    • 2019-10-23
    相关资源
    最近更新 更多