如何在Maven中正确使用Wildfly的jar? [英] How to use jars from Wildfly correctly in Maven?

查看:273
本文介绍了如何在Maven中正确使用Wildfly的jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目以部署到Wildfly,并且正在使用Maven进行构建.这是一个包含多个war/jar/ear文件的复杂项目,因此存在一个父pom.xml,其中包含以下内容:

I'm working on a project to deploy to Wildfly, and I'm using Maven to build it. This is a complex project with multiple war/jar/ear files, so there's a parent pom.xml with the following in it:

...
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.wildfly.bom</groupId>
      <artifactId>jboss-javaee-7.0-with-all</artifactId>
      <version>8.1.0.Final</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
...
  </dependencies>
</dependencyManagement>
...

不幸的是,上面的BOM不包含我知道的默认Wildfly 8.1.0.Final发行版中的各种jar文件.特别是,此问题的原因是cxf-api jar文件.我知道它位于Wildfly的这个位置:

Unfortunately, the above BOM does not include various jar files that I know are in the default Wildfly 8.1.0.Final distribution. In particular, the cause of this question is the cxf-api jar file. I know it resides at this location in Wildfly:

wildfly-8.1.0.Final/modules/system/layers/base/org/apache/cxf/main/cxf-api-2.7.11.jar

,但不受Wildfly建议的BOM进行管理.

but it is not being managed by the BOM recommended for Wildfly.

我如何正确将cxf-api和类似的jar文件添加到项目的pom.xml中,最好不必单独指定每个文件?当然,我可以做这样的事情:

How do I correctly add cxf-api, and similar jar files, to the project's pom.xml, preferably without having to specify each one individually? Sure, I could do something like this:

<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-api</artifactId>
  <version>2.7.11</version>
  <scope>provided</scope>
</dependency>

但是我真的不想对已经成为Wildfly一部分的每个jar文件执行此操作.

but I'd really rather not have to do this for each and every jar file that is already a part of Wildfly.

没有可以导入的BOM表吗?

Isn't there a BOM that I can import?

推荐答案

WildFly BOMs (原始版本为JBoss物料清单)是一组使用的依赖项增强相关项目的部署并以某种方式使其测试自动化.不幸的是,它不包含 WildFly 核心(即应用服务器)中使用的依赖项.

WildFly BOMs (aka JBoss Bill of Materials in its original version) is a set of dependencies used to enhance deployment of dependant projects and automate in some way their tests. It does not unfortunately includes dependencies used in WildFly core i.e. the Application Server.

您真正需要导入的 pom.xml (项目描述符)就是

The pom.xml (project descriptor) that you really need to import just the way you did for your BOMs pom file is the WildFly parent pom. So just import it into your own project pom and you will have your dependecies transitevelly resolved:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.wildfly</groupId>
      <artifactId>wildfly-parent</artifactId>
      <version>8.1.0.Final</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

检出 Apache CXF版本在目标 WildFly 版本中,只需选择符合您需求的稳定标签即可.

Checkout the Apache CXF version used in the target WildFly version and just pick up the stable tags that match your needs.

这篇关于如何在Maven中正确使用Wildfly的jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆