1
resposta

erro de persistencia

Boa tarde.

Estou usando o banco Mysql, porem minha classe esta dando erro abaixo:

jun. 29, 2021 3:11:20 PM org.hibernate.jpa.boot.internal.PersistenceXmlParser doResolve
INFO: HHH000318: Could not find any META-INF/persistence.xml file in the classpath
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named loja
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
    at com.hithub.paulocesar.loja.testes.CadastroDeProduto.main(CadastroDeProduto.java:21)

Segue o arquivo .xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 

   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_2_0.xsd">
    <persistence-unit name="loja-loja" transaction-type="RESOURCE_LOCAL">


        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="loja_springboot" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="teste" />

            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />

        </properties>

    </persistence-unit>


</persistence>
1 resposta

Ao invés de

<persistence-unit name="loja-loja" transaction-type="RESOURCE_LOCAL">

deixe conforme abaixo

<persistence-unit name="loja" transaction-type="RESOURCE_LOCAL">