Mysql JPA-没有名为{{NAME_HERE}}的EntityManager的持久性提供程序

Mysql JPA-没有名为{{NAME_HERE}}的EntityManager的持久性提供程序,mysql,hibernate,jpa,jakarta-ee,glassfish,Mysql,Hibernate,Jpa,Jakarta Ee,Glassfish,我正要为一个新应用程序创建一个后端,但我在配置JPA时遇到了麻烦。 我正在使用GlassFish 5.0.0和Hibernate 5.4.5.Final与MySQL一起使用 我得到的错误是: javax.servlet.ServletException:javax.persistence.PersistenceException:没有名为applicationDB的EntityManager的持久性提供程序 persistence.xml: <?xml version="1.0" enco

我正要为一个新应用程序创建一个后端,但我在配置
JPA
时遇到了麻烦。 我正在使用GlassFish 5.0.0和Hibernate 5.4.5.Final与MySQL一起使用

我得到的错误是:

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

persistence.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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_2.xsd"
             version="2.2">

    <persistence-unit name="applicationDB">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <class>entities.CityEntity</class>
        <properties>
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/world?serverTimezone=GMT"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
            <property name="hibernate.connection.username" value="root"/>
            <property name="hibernate.connection.password" value="PASSWORD_HERE"/>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
        </properties>
    </persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>backend</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.4.5.Final</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.11</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
    </build>


</project>
persistence.xml
位于
project/src/main/resources/META-INF

我访问了我的一个REST端点,它反过来调用了应该测试JPA的方法,该方法基本上是这样做的:

 EntityManagerFactory emf = Persistence.createEntityManagerFactory("applicationDB");
 EntityManager em = emf.createEntityManager();
 System.out.println("Entity: " + em.find(CityEntity.class, 5));
我看不出问题,有什么建议吗?

你看到了吗?
它建议使用
hibernate core.jar
而不是弃用的
hibernate entitymanager

我将其替换为
hibernate core
version
5.4.6。最终
,同样的错误也会发生。我想您确实验证了hibernate jar是否已打包到您的WAR存档中了?或者您事先将它们部署到Glassfish了吗?我正在使用IntelliJ和“部署”分解的war归档,我在IntelliJOK的
外部库下有包括Hibernate core在内的所有依赖项,因此您可以验证部署的分解war是否包含Hibernate类?我不熟悉在IntelliJ中部署爆炸式归档。添加了所有已解决的libs maven,仍然相同…,好吧,我会想办法的,我想,我要感谢您的时间和帮助。