1
resposta

javax.persistence.PersistenceException

eu isso o eclipse e preferia usar o mysql em vez do mariadb e mesmo usando o mariadb nao funciona

package br.com.alura.jpa.teste;

import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence;

public class TesteCriaTabelas { public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory("contas"); EntityManager createEntityManager = emf.createEntityManager(); emf.close(); }

}

package br.com.alura.jpa.modelo;

import javax.persistence.Entity;

@Entity public class Conta { private Long id; private Integer agencia; private Integer numero; private String titular;

public Long getId() {
    return id;
}
public void setId(Long id) {
    this.id = id;
}
public Integer getAgencia() {
    return agencia;
}
public void setAgencia(Integer agencia) {
    this.agencia = agencia;
}
public Integer getNumero() {
    return numero;
}
public void setNumero(Integer numero) {
    this.numero = numero;
}
public String getTitular() {
    return titular;
}
public void setTitular(String titular) {
    this.titular = titular;
}

}

br.com.alura.jpa.modelo.Conta

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

4.0.0 br.com.alura.jpa projeto.jpa 0.0.1-SNAPSHOT

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-agroal</artifactId>
        <version>5.4.10.Final</version>
        <type>pom</type>

    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.22</version>
    </dependency>
</dependencies>
--------------------------------------------------------------------------- erro apresentado dez 02, 2020 3:06:11 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 contas at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at br.com.alura.jpa.teste.TesteCriaTabelas.main(TesteCriaTabelas.java:9)
1 resposta