通过Maven支持多个应用服务器 [英] Support multiple application servers through 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.xml
或build.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?
推荐答案
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屋!