xml如下所示:
<persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <non-jta-data-source>jdbc/test</non-jta-data-source> <jar-file>../../lib/app-services-1.0.jar</jar-file> <exclude-unlisted-classes>false</exclude-unlisted-classes> </persistence-unit>
它是一个Web项目,所以部署单元是一个WAR文件
Example 1: app.ear lib/earEntities.jar earRootPUnit.jar (with META-INF/persistence.xml ) persistence.xml contains: <jar-file>lib/earEntities.jar</jar-file> Example 2: app.ear lib/earEntities.jar lib/earLibPUnit.jar (with META-INF/persistence.xml ) persistence.xml contains: <jar-file>earEntities.jar</jar-file> Example 3: app.ear lib/earEntities.jar ejbjar.jar (with META-INF/persistence.xml ) persistence.xml contains: <jar-file>lib/earEntities.jar</jar-file> Example 4: app.ear war1.war WEB-INF/lib/warEntities.jar WEB-INF/lib/warPUnit.jar (with META-INF/persistence.xml ) persistence.xml contains: <jar-file>warEntities.jar</jar-file> Example 5: app.ear war2.war WEB-INF/lib/warEntities.jar WEB-INF/classes/META-INF/persistence.xml persistence.xml contains: <jar-file>lib/warEntities.jar</jar-file> Example 6: app.ear lib/earEntities.jar war2.war WEB-INF/classes/META-INF/persistence.xml persistence.xml contains: <jar-file>../../lib/earEntities.jar</jar-file> Example 7: app.ear lib/earEntities.jar war1.war WEB-INF/lib/warPUnit.jar (with META-INF/persistence.xml ) persistence.xml contains: <jar-file>../../../lib/earEntities.jar</jar-file>