简体   繁体   English

EJB-JAR中的第三方库

[英]Third Party Libraries in EJB-JAR

at time i try to add third party libraries in a EJB-JAR. 当时我尝试在EJB-JAR中添加第三方库。 So far it seems to me, that it is not possible, but i am not sure, and why it is not possible. 到目前为止,在我看来,这是不可能的,但是我不确定,以及为什么这是不可能的。

I want to create single EJB-JARs and WARs, without put them together in one EAR. 我想创建单个EJB-JAR和WAR,而无需将它们放在一起放在一个EAR中。

Arjan Tijms shows in Java EE - EAR vs separate EJB+WAR three ways, and to clearify it, i want option 2. Arjan Tijms在Java EE中展示了EAR vs分离的EJB + WAR三种方式,为澄清起见,我想要选项2。

My own research comes mostly to questions with following answers J2EE: How to package 3rd party JARs into an EJB jar? 我自己的研究主要涉及以下问题的答案J2EE:如何将第三方JAR打包到EJB jar中? , but i don't want an EAR file. ,但我不需要EAR文件。

On the oracle site itself shows following packaging for an EJB-JAR: EJB packaging , which don't have a own lib directory like a WAR. 在oracle站点本身上,显示了EJB-JAR的以下打包: EJB包装 ,它没有像WAR这样的自己的lib目录。 I already tried to put the libary in the root directory (Using eclipse + JBoss 7). 我已经尝试将库放在根目录中(使用eclipse + JBoss 7)。 My first question is, is it possible to add extra libaries into a EJB-JAR, like in a WAR file? 我的第一个问题是,是否可以像在WAR文件中一样将额外的库添加到EJB-JAR中? This confuses me, because it is possible to deploy a simple EJB-JAR to a application server, but it seems you cannot add third party libaries. 这使我感到困惑,因为可以将简单的EJB-JAR部署到应用程序服务器,但是似乎您无法添加第三方库。 For me a EAR seems mostly "overkill", because it have for me no real advantage and second, if i put a library into a EAR, different EJB-JARs connot use different versions from third party libraries. 对我来说,EAR似乎主要是“过度杀伤力”,因为它对我而言没有真正的优势,其次,如果我将库放入EAR,则不同的EJB-JAR不会使用与第三方库不同的版本。 I want the EJB-JAR complete independent from other EJB-JARs and WARs. 我希望EJB-JAR完全独立于其他EJB-JAR和WAR。 I only created a additional simple jar project that contains the interfaces, that have to be implemented, and is added to each EJB project and the WAR project. 我仅创建了另一个简单的jar项目,其中包含必须实现的接口,并将其添加到每个EJB项目和WAR项目中。 That brings me to question 2: Have i use to an EAR, if yes, why? 这使我想到了问题2:我是否习惯使用EAR,如果可以,为什么? It seems to me that i missing something oder don't understand yet. 在我看来,我还缺少一些尚不了解的东西。

You can put third party JARs in a lib/ folder in the EAR and add 您可以将第三方JAR放在EAR的lib/文件夹中并添加

<library-directory>lib</library-directory>

to your application.xml . 到您的application.xml

Jars aren't supposed to contain jars. 罐子不应该包含罐子。

I would just package the EJBs into a WAR (either directly in WEB-INF/classes or as separate ejb-jars in WEB-INF/lib), put the 3rd party libs into WEB-INF/lib and call it a day. 我只是将EJB打包到WAR中(直接在WEB-INF / classs中或在WEB-INF / lib中作为单独的ejb-jars),将第3方库放到WEB-INF / lib中,并称之为一天。 Your approach is pretty limiting. 您的方法很局限。 You won't be able to inject your EJBs, and you would have to use a remote lookup. 您将无法注入EJB,并且必须使用远程查找。

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

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