javax.persistence.PersistenceException:未找到[PersistenceUnit:vodPersistenceUnit]类或包 [英] javax.persistence.PersistenceException : [PersistenceUnit: vodPersistenceUnit] class or package not found
问题描述
出现以下错误:
创建名称为
的bean时出错org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor #0'
在类路径资源[jpaDaoContext.xml]中定义:初始化
bean失败;嵌套的异常是
org.springframework.beans.factory.BeanCreationException:错误
在类b $ b中定义了名为'vodEntityManagerFactory'的Bean路径资源[jpaDaoContext.xml]:调用init方法失败;
嵌套异常是javax.persistence.PersistenceException:
[PersistenceUnit:vodPersistenceUnit]类或包未找到
我看了一下Google,并被告知要选择transaction-type = RESOURCE_LOCAL,但设置已经这样。这些设置有什么问题:
<?xml version =1.0encoding =UTF-8?>
< 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>
<! - transaction-type是RESOURCE_LOCAL或JTA - >
< persistence-unit name =vodPersistenceUnit
transaction-type =RESOURCE_LOCAL>
< class> mypackage.persistent.HistoriqueAction< / class>
< class> mypackage.persistent.ParametresTechniques< / class>
< class> mypackage.persistent.TicketType< / class>
< class> mypackage.persistent.TransactionType< / class>
< class> mypackage.persistent.StatutSession< / class>
< class> mypackage.persistent.Statistique< / class>
< class> mypackage.persistent.StatUser< / class>
<! - 避免扫描* .class和* .hbm.xml - >
< exclude-unlisted-classes />
< / persistence-unit>
< /持久性>
问候
<! - class> mypackage.persistent .TicketType< /类>
< class> mypackage.persistent.TransactionType< / class>
< class> mypackage.persistent.StatutSession< / class - >
目前我不知道为什么它解决了这个问题。调试这个spring文件真的很难。
I got the following error :
Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [jpaDaoContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vodEntityManagerFactory' defined in class path resource [jpaDaoContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: vodPersistenceUnit] class or package not found
I had a look on Google and I was told to choose transaction-type=RESOURCE_LOCAL but the settings were already that way. What is wrong with these settings :
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- transaction-type is RESOURCE_LOCAL or JTA -->
<persistence-unit name="vodPersistenceUnit"
transaction-type="RESOURCE_LOCAL">
<class>mypackage.persistent.HistoriqueAction</class>
<class>mypackage.persistent.ParametresTechniques</class>
<class>mypackage.persistent.TicketType</class>
<class>mypackage.persistent.TransactionType</class>
<class>mypackage.persistent.StatutSession</class>
<class>mypackage.persistent.Statistique</class>
<class>mypackage.persistent.StatUser</class>
<!-- Avoid to scan *.class and *.hbm.xml -->
<exclude-unlisted-classes />
</persistence-unit>
</persistence>
Regards
I fixed the issue. I had to comment these three lines in the file "persistence.xml" :
<!--class>mypackage.persistent.TicketType</class>
<class>mypackage.persistent.TransactionType</class>
<class>mypackage.persistent.StatutSession</class-->
For the moment i have no idea why it fixes the issue. It is really hard to debug this spring file.
这篇关于javax.persistence.PersistenceException:未找到[PersistenceUnit:vodPersistenceUnit]类或包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!