Versão atual:

Problema com JPA

Ao tentar rodar um simples exercicio de jpa2 e hibernate ocorre o seguinte erro

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named K21_livraria_pu
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
    at br.com.k19.testes.GeraTabelas.main(GeraTabelas.java:11)

Minha classe Editora

package br.com.k19.modelo;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
public class Editora implements Serializable {


    /**
     * 
     */
    private static final long serialVersionUID = 6424558653607630700L;

    @Id @GeneratedValue
    private Long id;

    private String nome;
    private String email;


    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getNome() {
        return nome;
    }
    public void setNome(String nome) {
        this.nome = nome;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }




}

Minha Classe GeraTabelas

package br.com.k19.testes;

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

public class GeraTabelas {

    public static void main(String[] args) {

        EntityManagerFactory factory = 
            Persistence.createEntityManagerFactory("K21_livraria_pu");
        factory.close();

    }

}

e meu persistence.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="K21_livraria_pu"
        transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>br.com.k19.modelo.Editora</class>


        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="javax.persistence.jdbc.user" value="root"/>
            <property name="javax.persistence.jdbc.password" value="root"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/k21_livraria_bd"/>
        </properties>
    </persistence-unit>
</persistence>

Como resolvo este problema? desde já muito obrigado

https://www.filepicker.io/api/file/HGR9e4yhSDezUyOe2N93

Versão(1):

Ver a versão formatada

Problema com JPA

Comentário

new question