如何为 EAR 的 application.xml 中的模块指定类路径
所以我有一个包含所有模块的 EAR。所有模块使用的共享 JAR 都放置在 EAR 的默认 ./lib/ 文件夹中。我还有多个版本的 JAR 文件,每个模块将使用其一个版本。例如,如果我的 EAR 中有以下战争:
project1.war
project2.war
project3.war
并且我有几个 JAR 文件:
common-classes-1.0.jar
common-classes-1.1.jar
那么,如何将project1 与common-classes-1.0.jar 关联,以及project2 和project3 与common-classes-1.1.jar 关联?
提前致谢
So I have an EAR that contains all of my modules. The shared JARs that are used by all the modules are placed in the default ./lib/ folder of the EAR. I also have multiple version of a JAR file that each module will use a version of. For example, if I have the following wars in my EAR:
project1.war
project2.war
project3.war
And I have a couple of JAR files:
common-classes-1.0.jar
common-classes-1.1.jar
So, how can I associate project1 with common-classes-1.0.jar, and project2 and project3 with common-classes-1.1.jar?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者,您可以“重新打包”您的 war 文件以包含所需的 commons Jars。通过这种方式,您可以保留单个 EAR 文件。
Alternatively, you can "repackage" your war files to include the desidered commons Jars. In this way, you can keep a single EAR file.
你不能; EAR 对其类路径没有这种级别的精细控制,除非您的应用程序服务器具有允许您执行此操作的非标准扩展。
这是 OSGi 设计的用例,但标准 JavaEE EAR 无法做到这一点。
最简单的选择是将 EAR 分成 2 个,一个包含
project1.war
和common-classes-1.0.jar
,另一个包含project2.war
、project3.war
和common-classes-1.1.jar
。You can't; EARs don't have that level of fine control over their classpath, unless your app-server has non-standard extensions that let you do this.
This is the sort of use-case that OSGi was designed for, but standard JavaEE EARs can't do this.
Your simplest option is to break up your EAR into 2, one with
project1.war
andcommon-classes-1.0.jar
, and the other withproject2.war
,project3.war
andcommon-classes-1.1.jar
.