java 如何将第 3 方 JAR 打包到 EJB jar 中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1364544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 16:16:11  来源:igfitidea点击:

How to package 3rd party JARs into an EJB jar?

javajakarta-eeear

提问by Tong Wang

I have an old J2EE application (J2EE 1.3), which packages into an EAR, and in the EAR, there are WARs and EJB JARs. Now one of the EJB JARs needs to refer to some 3rd party library JARs, so what's the best place to package those JARs and how?

我有一个旧的 J2EE 应用程序 (J2EE 1.3),它打包到一个 EAR 中,在 EAR 中,有 WAR 和 EJB JAR。现在其中一个 EJB JAR 需要引用一些 3rd 方库 JAR,那么打包这些 JAR 的最佳位置是什么?如何打包?

回答by Robin

They go in the ear file, at the root or you can create a libdirectory to store them. Any project (EJB or WAR) that needs to reference them must include them in the Class-Path:of the manifest file.

它们位于根目录下的 ear 文件中,或者您可以创建一个lib目录来存储它们。任何需要引用它们的项目(EJB 或 WAR)都必须将它们包含在清单文件的 Class-Path:中。

Ear contents

耳朵内容物

  - log4j.jar
  - lib
     - commons-lang.jar
  - MyEJBProj.jar
  - MyWAR.war

MyEJBProj contents

MyEJBProj 内容

 - classes
 - META-INF
    - MANIFEST.MF

MANIFEST.MF

清单文件

    Manifest-Version: 1.0
    Class-Path: log4j.jar lib/commons-lang.jar