开发者

How to reuse EJB in Java EE 5+

开发者 https://www.devze.com 2023-02-02 22:38 出处:网络
I have a few common entity beans that I want to use开发者_Python百科 in EJB module1, and EJB module2.EJB module1 may or may not be in the same EAR as EJB module2 and both EJB modules will be persist t

I have a few common entity beans that I want to use开发者_Python百科 in EJB module1, and EJB module2. EJB module1 may or may not be in the same EAR as EJB module2 and both EJB modules will be persist to different databases. What's the best way to reuse the common EJBs? should they be package as a JAR file or as EJB jar file?


After playing around with it a bit packaging the common EJBs in it's own EJB jar makes the most sense.

  1. Create an EJB project and add common entity beans. No persistence.xml file is need for this project

  2. Export the project as an EJB jar file.

  3. Add the jar file to the dependant EJB modules. Be sure to add the classes name in the persistence-unit of the dependant EJB modules's persistence.xml.

Hopefully this help someone with similar newbie question.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号