已将persistence.xml放在eclipse中项目的类路径中,因为在错误之前找不到该文件.现在给出了这个错误:
引发者:javax.persistence.PersistenceException:无效的persistence.xml.解析XML时出错[line:-1,column:-1]:cvc-elt.1:找不到元素'persistence'的声明
org.hibernate.ejb.HibernatePersistence
Marcel Stör.. 37
问题是你混合了JPA 2.0和JPA 2.1表示法.
这个
对于JPA 2.1或此
对于JPA 2而不是其混合.
有关详细信息,请参阅http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/index.html.
问题是你混合了JPA 2.0和JPA 2.1表示法.
这个
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">
对于JPA 2.1或此
<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_2_0.xsd" version="2.0">
对于JPA 2而不是其混合.
有关详细信息,请参阅http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/index.html.