【问题标题】:Override parent pom dependency覆盖父 pom 依赖
【发布时间】:2023-03-10 12:55:01
【问题描述】:

我用 maven 和 wildfly 做了一个简单的 EAR 项目,但是我遇到了一些过时依赖项的问题。

项目结构如下:

Project
  --EarProject
  --BaseProject
  --WarProject
  --EjbProject

在父项目的pom中有依赖:

<dependency>
    <groupId>org.wildfly.bom</groupId>
    <artifactId>jboss-javaee-7.0-with-tools</artifactId>
    <version>${version.jboss.bom}</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>

在 BaseProject 的 pom 中我使用 Selenium:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-driver</artifactId>
</dependency>

问题在于,在 BaseProject Maven 库中,我看到了旧版本的 Selenium(即 selenium-firefox-driver 2.40.0 而不是新的 2.44.0),并且由于 2.40.0 中的错误,我的应用程序无法正常工作。 我尝试添加:

<version>2.44.0</version>

在 BaseProject 的 pom 中,但我收到了类似

的警告

覆盖 selenium-remote-driver 的托管版本 2.40.0

它不起作用。

如何覆盖父 pom 中的依赖版本或从 jboss-javaee-7.0-with-tools 依赖中排除 selenium?

【问题讨论】:

    标签: maven selenium dependencies


    【解决方案1】:

    如何覆盖父 pom 中的依赖版本

    “覆盖 selenium-remote-driver 的托管版本 2.40.0”警告只是一个 m2e 警告不是一个 Maven 警告。使用您的代码,您正确地覆盖了父 pom 的依赖版本。 See this bug at Eclipse site for m2e about this warning。您可以通过查看依赖关系树来断言(在 Eclipse 中或使用 mvn dependency:tree 命令)

    或者从 jboss-javaee-7.0-with-tools 依赖项中排除 selenium?

    您可以使用exclusions 标签来做到这一点。它是一个标签,您可以在其中指定要从 Maven 解析的传递依赖项中排除的每个 groupId 和 artifactId。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-12
      • 1970-01-01
      • 2016-12-17
      相关资源
      最近更新 更多