简体   繁体   English

ear文件中有多个相同的jar文件

[英]Multiple identical jar files in an ear file

I have produced an ear file with a war file inside but the ear file contains jar files which are already in the lib folder of the war file. 我已经生成了一个带有war文件的ear文件,但是ear文件包含jar文件,这些文件已经存在于war文件的lib文件夹中。 How can I remove the duplicate jar files and where should those jar files be? 如何删除重复的jar文件以及这些jar文件应该在哪里? In the war file's lib folder or outside the war file? 在war文件的lib文件夹中或war文件外? (I am using maven ear plugin and maven war plugin in my project). (我在我的项目中使用maven ear插件和maven war插件)。

I finally figured out a way to do this by producing skinny war files inside an ear file. 我终于通过在ear文件中生成瘦的war文件找到了一种方法。 I was inspired by the maven-war-plugin example from here skinny-wars 我受到了来自瘦弱战争的maven-war-plugin示例的启发

Followed the instructions of the example, I moved all the jar files out of the war module and put it into a lib folder within ear file. 按照示例的说明,我将所有jar文件移出war模块并将其放入ear文件中的lib文件夹中。

So the final ear file structure will be: 所以最终的ear文件结构将是:

  ear-app
   -- lib (all the jar files will be here)
   -- webModule1
      -- lib (empty)
   -- webModule2
      -- lib (empty)
   -- ejbModule

If you have jars that are used by both, the EJB archive and the WEB archive, then you can do the following: 如果您拥有EJB存档和WEB存档使用的jar,那么您可以执行以下操作:

  1. keep all the common jars at the root of the .ear 将所有常见的罐子放在.ear的根部
  2. use the Class-Path attribute of the manifest.mf in the ejb and web archives to refer to these jar files. 使用ejb和web存档中manifest.mf的Class-Path属性来引用这些jar文件。 Remember that the location of the jars will be relative to the root of the ear file. 请记住,罐子的位置将相对于ear文件的根目录。

Even if you don't have an EJB jar, the above steps will work. 即使您没有EJB jar,上述步骤也可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM