做这个:
1)将 jboss-classloading.xml 添加到 /src/main/webapp (我使用的是 Maven):
内容:
<?xml version="1.0" encoding="UTF-8"?>
<classloading xmlns="urn:jboss:classloading:1.0"
domain="$UNIQUE_DOMAIN_NAME"
export-all="NON_EMPTY"
import-all="false"
parent-first="false">
</classloading>
2) 修改$JBOSS_INSTALL_DIRECTORY/jboss-as/server/$PROFILE/conf/bootstrap/deployers.xml,在末尾添加如下内容:
<bean name="IgnoreFilesDeployer"
class="org.jboss.deployers.vfs.spi.deployer.AbstractIgnoreFilesDeployer"
</bean>
3)在META-INF文件夹中创建一个文件JBOSS-IGNORE.TXT,内容如下:
WEB-INF/classes/META-INF/persistence.xml
4)我已将我的 persistence.xml 重命名为 spring-persistence.xml 并将此文件添加到 context.xml 中:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:/META-INF/spring-persistence.xml"/>
....
</bean>
5)我还修改了spring-persistence.xml(保存在webapp\META-INF文件夹中的persistence_2_0.xsd)为
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="file:///persistence_2_0.xsd
http://java.sun.com/xml/ns/persistence">
....
</persistence>