没有针对EntityManager的持久性提供程序更多

时间:2017-05-26 18:30:10

标签: java hibernate jpa playframework-2.5 persistence.xml

我一直在使用Play Framework 2.5创建一个应用程序,并且在使用run命令以dev模式运行它时没有任何问题,但是一旦我尝试切换到prod模式,我就有这个例外:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named defaultPersistenceUnit

我的persistence.xml位于conf / META-INF /文件夹

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

<persistence-unit name="defaultPersistenceUnit"
    transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>

    <class>models.entities.Artifact</class>

    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="hibernate.hbm2ddl.auto" value="update" />
        <property name="hibernate.show_sql" value="false" />
        <property name="hibernate.format_sql" value="true" />
        <property name="current_session_context_class" value="thread" />
    </properties>
</persistence-unit>

<persistence-unit name="testPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <class>models.entities.Artifact</class>
    <properties>
        <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test" />
        <property name="javax.persistence.jdbc.user" value="" />
        <property name="javax.persistence.jdbc.password" value="" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
        <property name="hibernate.hbm2ddl.auto" value="create-drop" />
        <property name="show_sql" value="false" />
        <property name="hibernate.temp.use_jdbc_metadata_defaults"
            value="false" />
    </properties>
</persistence-unit>

请至少告诉我一些可能出现问题的线索

0 个答案:

没有答案