小编典典

javax.persistence.PersistenceException:[找不到PersistenceUnit:vodPersistenceUnit]类或包

hibernate

我收到以下错误:

在类路径资源[jpaDaoContext.xml]中定义的名称为’org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0’的bean创建时出错:bean的初始化失败;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建在类路径资源[jpaDaoContext.xml]中定义的名称为’vodEntityManagerFactory’的bean时出错:调用init方法失败;嵌套的异常是javax.persistence.PersistenceException:[PersistenceUnit:vodPersistenceUnit]类或包未找到

我在Google上进行了查看,并被告知选择transaction-type = RESOURCE_LOCAL,但是设置已经是这样。这些设置有什么问题:

 <?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>

问候


阅读 385

收藏
2020-06-20

共1个答案

小编典典

我解决了这个问题。我必须在文件“ persistence.xml”中注释这三行:

   <!--class>mypackage.persistent.TicketType</class>
    <class>mypackage.persistent.TransactionType</class>
    <class>mypackage.persistent.StatutSession</class-->

目前,我不知道为什么它可以解决这个问题。调试这个spring文件确实很难。

2020-06-20