我在tomcat上使用hibernate JPA。我在tomcat上创建了一个连接池,它独立运行良好。现在,为了让我的JPA使用这个连接池,我创建了persistence.xml,如下所示:
<?xml version="1.0"?>
<persistence>
<persistence-unit name="kids" transaction-type="JTA">
<jta-data-source>jdbc/kids</jta-data-source>
</persistence-unit>
</persistence>它给了我以下例外:
javax.persistence.PersistenceException:无效的persistence.xml。分析XML时出错(第-1行:第-1列):cvc-elt.1:找不到元素'persistence‘的声明。
请帮帮忙。
发布于 2012-04-19 23:15:19
也许您应该为持久性节点设置名称空间属性和模式位置:
<persistence 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"
version="1.0">
<persistence-unit name="kids" transaction-type="JTA">
<jta-data-source>jdbc/kids</jta-data-source>
</persistence-unit>
</persistence>https://stackoverflow.com/questions/10231085
复制相似问题