Boa tarde,
Pessoal estava estudando Maven com Eclipse, mas acabei travando neste erro.
Já procurei no fórum erros parecidos, mas nenhum resolveu meu problema.
Se alguém conseguir me ajudar, eu agradeço.
Fonte
[code]<?xml version="1.0" encoding="UTF-8"?>
org.hibernate.ejb.HibernatePersistence
[/code]
[code]package br.com.dkjavaweb.entidade.util;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class JPAUtil {
private static EntityManagerFactory emf =
Persistence.createEntityManagerFactory("default");
public static EntityManager getEntityManager(){
return emf.createEntityManager();
}
}
[/code]
[code]package dkjavaweb;
import javax.persistence.EntityManager;
import br.com.dkjavaweb.entidade.Usuario;
import br.com.dkjavaweb.entidade.util.JPAUtil;
public class JPATeste {
public static void main(String[] agrs){
Usuario novo = new Usuario();
EntityManager em = JPAUtil.getEntityManager();
novo.setNome("Zé");
novo.setEmail("ze@gmail.com");
novo.setSenha("123abc");
em.getTransaction().begin();
em.persist(novo);
em.getTransaction().commit();
}
}
[/code]
[code]
4.0.0
br.com.dk
dkjavaweb
0.0.1-SNAPSHOT
war
dkjavaweb
Projeto Java Web Avançado
<!-- Propriedades -->
<properties>
<hibernate.groupid>org.hibernate</hibernate.groupid>
<hibernate.version>4.3.4.Final</hibernate.version>
<slf4j.version>1.7.6</slf4j.version>
<postgresql.version>9.1-901.jdbc4</postgresql.version>
</properties>
<!-- Propriedades -->
<dependencies>
<!-- Dependecia do Hibernate -->
<dependency>
<groupId>${hibernate.groupid}</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Banco de Dados -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<!-- Banco de Dados -->
</dependencies>
[/code]
Erro:
xception in thread "main" java.lang.ExceptionInInitializerError
at dkjavaweb.JPATeste.main(JPATeste.java:13)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named default
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at br.com.dkjavaweb.entidade.util.JPAUtil.<clinit>(JPAUtil.java:10)
... 1 more