我正在使用eclipse中的spring jpa hibernate項目。我有一個錯誤在我的persistence.xml文件,但我不知道確切位置:解決方案無效persistence.xml
我的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="hibernatePersistenceUnit" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="show_sql">true</property>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
</properties>
<mapping-file>META-INF/orm.xml</mapping-file>
</persistence-unit>
</persistence>
我得到錯誤像這樣:
javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML (line-1 : column -1): cvc-complex-type.4: Attribute 'value' must appear on element 'property'.
Error parsing XML (line-1 : column -1): cvc-complex-type.2.1: Element 'property' must have no character or element information item [children], because the type's content type is empty.
Error parsing XML (line-1 : column -1): cvc-complex-type.2.4.d: Invalid content was found starting with element 'mapping-file'. No child element is expected at this point.
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:145)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:169)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:317)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:46)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:30)
at org.krams.repository.CustomerDAO.addCustomer(CustomerDAO.java:38)
at org.krams.repository.CustomerDAO$$FastClassByCGLIB$$60d23388.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
可以在任何幫助我解決這個問題。
閱讀,似乎一切都OK。我在腳本中唯一的區別(除了映射文件 - 我們使用註釋)是第一行: –
您使用Netbeans嗎?如果是,則重命名當前持久性,並生成一個新的比較結果。昨天我用這種方法糾正了一個類似的問題。 –