javax.persistence.PersistenceException:没有名为em1的EntityManager的持久性提供程序

时间:2018-04-24 16:06:39

标签: java mysql jpa glassfish

我正在Glassfish中创建一个服务器,我想要一个JPA持久层到远程MySQL数据库。

当我尝试使用持久层时,我得到了这个例外:javax.persistence.PersistenceException: No Persistence provider for EntityManager named em1

基于其他StackOverflow帖子,似乎这表明persistence.xml无效。我的persistence.xml显示。有人能指出我正确的方向来弄清楚如何让它发挥作用吗?

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name ="em1">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>data.entry.Movie</class>
        <properties>
            <property name="eclipselink.target-database"
                      value="MySQL4"/>

            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="mysql3.cs.myschool.edu/mydb"/>
            <property name="javax.persistence.jdbc.user" value="mydb" />
            <property name="javax.persistence.jdbc.password" value="mypass" />
        </properties>
    </persistence-unit>
</persistence>

0 个答案:

没有答案