我们创建了一些库,所有的项目都将使用这些库,这些库将为我们所有系统提供基本功能(例如登录、一些管理等)。但应用程序本身可以使用另一个数据库。
我们创建了一个带有两个持久化单元的Persistence.xml。并将所有核心库实体打包到名为“LN-model.jar”的jar中,并将所有测试应用程序实体打包到“App-model.jar”中。但是出现了以下消息:
“在模块范围内,无法解析与持续性上下文引用名称[x.x.x.x.listener.InicializadorListener/em]相对应的持续性单元,该模块的名称为[gfdeploy#/Users/zkropotkine/WORK/SeguridadCore/dist/gfdeploy/SeguridadCore-war_war]。请检查您的应用程序。”
以下是我们的Persistence.xml:
我们创建了一个带有两个持久化单元的Persistence.xml。并将所有核心库实体打包到名为“LN-model.jar”的jar中,并将所有测试应用程序实体打包到“App-model.jar”中。但是出现了以下消息:
“在模块范围内,无法解析与持续性上下文引用名称[x.x.x.x.listener.InicializadorListener/em]相对应的持续性单元,该模块的名称为[gfdeploy#/Users/zkropotkine/WORK/SeguridadCore/dist/gfdeploy/SeguridadCore-war_war]。请检查您的应用程序。”
以下是我们的Persistence.xml:
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="x" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/x</jta-data-source>
<jar-file>App-model.jar</jar-file>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
</properties>
</persistence-unit>
<persistence-unit name="y" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/y</jta-data-source>
<jar-file>LN-model.jar</jar-file>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
顺便提一下,我们将Persistence.xml放在一个jar包中,然后将其添加到企业项目(EAR)中。