通过Maven支持多个应用服务器 [英] Support multiple application servers through Maven

查看:128
本文介绍了通过Maven支持多个应用服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Java Web应用程序已部署在Wildfly上.但是,现在有一个客户端想要使用WebSphere.我们发现,war文件的lib文件夹中包含的jar文件在Wildfly和WebSphere之间需要有所不同-WebSphere不喜欢拥有一些Wildfly可以使用的库( AS提供了不同的库?).

We have a Java web application that is deployed on Wildfly. However, one client now wants to use WebSphere. We've found that the included jar files in the lib folder of our war file need to be a little different between Wildfly and WebSphere - WebSphere doesn't like having some of the libs that Wildfly is fine with (different libraries provided by the AS?).

我们想尽可能地自动化,尽管我认为在构建一个文件时可能会在pom.xmlbuild.xml文件中进行一些 手动修改.或其他.但是,有没有一种很好的,理智的方法来适当地过滤jar文件?我唯一能想到的就是在pom.xml文件中使用<exclusions>,但是除了要注释一堆<exclusions><scope>退出,这似乎是不切实际的.

We would like to automate this as much as possible, although I assume there's probably going to be some manual fiddling in a pom.xml or build.xml file when it comes time to build for one or the other. But is there a good, sane way to filter the jar files appropriately? The only thing I can think of is using <exclusions> in the pom.xml file, but I don't see how to sensibly control that if I want to build for one AS vs the other, other than just commenting a bunch of <exclusions> or <scope>s out, which seems impractical.

是否有可能以几乎完全自动化的方式通过Maven做到这一点?还是最好的方法是什么?

Is it possible to do this through Maven somehow, in a nearly totally automated fashion? Or what's the best way?

推荐答案

使用它们允许您激活/禁用POM的某些部分.因此,您定义了一个配置文件websphere和一个配置文件wildfly.您可以将供应商特定的依赖项放入配置文件中(也可以在每个配置文件中将相同的依赖项放入不同的排除项中).

They allow you to activate/deactivate parts of the POM. So you define a profile websphere and a profile wildfly. You put the vendor specific dependencies into the profiles (you can also put the same dependency in each of the profiles with different exclusions).

然后您可以通过命令行,settings.xml或通过缺少给定文件来激活/停用配置文件.

You can then activate/deactivate the profiles either from the command line, from the settings.xml or through the presence of absence of a given file.

这篇关于通过Maven支持多个应用服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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