Override parent pom dependency

懵懂的女人 提交于 2019-12-24 11:33:50

问题


I made a simple EAR project with maven and wildfly, but I have some problems with obsolete dependencies.

Project structure is like:

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

In parent Project's pom there is dependency:

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

And in BaseProject's pom I use Selenium:

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

The problem is that in BaseProject Maven libraries I see older versions of Selenium (ie. selenium-firefox-driver 2.40.0 instead of newer 2.44.0) and because of bugs in 2.40.0 my app does not work corectly. I tried to add:

<version>2.44.0</version>

in BaseProject's pom, but I got warning like

Overriding managed version 2.40.0 for selenium-remote-driver

and it does not work.

How can I override version of dependency from parent's pom or exclude selenium from jboss-javaee-7.0-with-tools dependency?


回答1:


How can I override version of dependency from parent's pom

The "Overriding managed version 2.40.0 for selenium-remote-driver" warning is a just a m2e warning not a Maven warning. With your code, you are correctly overriding the version of the dependency of the parent's pom. See this bug at Eclipse site for m2e about this warning. You can assert that by looking at the dependency tree (in Eclipse or with the mvn dependency:tree command)

or exclude selenium from jboss-javaee-7.0-with-tools dependency?

You can do that with the exclusions tag. It is a tag where you specify each groupId and artifactId that you want to exclude from the transitive dependencies resolved by Maven.



来源:https://stackoverflow.com/questions/28770922/override-parent-pom-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!