简体   繁体   English

Maven-不包括传递依赖项

[英]Maven - Excluding Transitive Dependencies

I am trying to exclude transitive dependency using following in the pom file 我正在尝试在pom文件中使用以下命令来排除传递依赖

 <dependency>
      <groupId>xxxxx</groupId>
      <artifactId>xxxxxx</artifactId>
       <exclusions>
          <exclusion>
            <groupId>yyyyyyy</groupId>
            <artifactId>yyyyyyy</artifactId>
          </exclusion>
        </exclusions>
    </dependency>

where xxxxxx is the project I need. xxxxxx是我需要的项目。 I am trying to avoid the transitive dependent project yyyyyy, that comes with it as it conflicts with the other version of the same project I already have as dependency. 我试图避免传递依赖项目yyyyyy,因为它与我已经具有依赖项的同一个项目的其他版本相冲突。

When i build my project with this configuration and refresh eclipse, the project yyyyyyy-version.jar still shows in my classpath entry. 当我使用此配置构建项目并刷新Eclipse时,项目yyyyyyy-version.jar仍显示在我的类路径条目中。 I have to manually delete that classpath entry to make it work. 我必须手动删除该类路径条目才能使其正常工作。

Please guide what am i doing wrong here. 请在这里指导我在做什么错。 How to specify the exclusion in pom file so that I don't get this classpath entry.Thanks. 如何在pom文件中指定排除项,这样我就不会得到此classpath条目。谢谢。

Update - I am not having any problem in the build but while i try to run the application , it find a particular parameter in 2 versions of a project - The desired one and the undesired one coming as a transitive dependency. 更新-我在构建中没有任何问题,但是当我尝试运行该应用程序时,它在项目的2个版本中找到了一个特定的参数-所需的一个和不需要的一个作为传递依赖项。

Perform mvn dependency:tree and analyze who has this transitive dependency too. 执行mvn dependency:tree并分析谁也具有此传递依赖项。 Currently, there is no global exclude feature but an appropriate JIRA issue exists. 当前,没有全局排除功能,但是存在适当的JIRA问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM