Olá, meu persistence está assim:
</persistence>
Estou utilizando o maven, segue meu pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.alura</groupId>
<artifactId>livraria</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<finalName>livraria</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-servlet-initializer</artifactId>
<version>3.0.19.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<version>2.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-cdi</artifactId>
<version>3.0.19.Final</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.4.Final</version>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>
</dependencies>
</project>
Fiz algumas coisas aqui e parece que o eclipse voltou a reconhecer meu persistense.xml. Em "properties" do meu projeto, fui em JPA e setei "Platform: Generic 2.0" e voltou a ser reconhecido.
Entretanto ainda não estou conseguindo consultar a base de dados.
Segue meu DAO:
public List<Aplicacao> listar(Integer pagina, Integer max){
int inicio = (pagina * max) - max;
EntityManagerFactory emf = Persistence.createEntityManagerFactory("livraria");
EntityManager em = emf.createEntityManager();
TypedQuery<Aplicacao> query = em.createQuery(
" select a from Aplicacao a ", Aplicacao.class);
List<Aplicacao> aplicacoes = query.getResultList();
return aplicacoes;
}
Recebo o seguinte erro:
GRAVE: Servlet.service() for servlet [br.com.alura.BaseApplication] in context with path [/livraria] threw exception
org.jboss.resteasy.spi.UnhandledException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named livraria