@vlucas981 escreveu:
Bom dia amigos, me ajudem com essa porcaria pelo amor de Deus.
Estou estudando JPA + Hibernate, utilizando a apostila da K19.
Fiz o exercício que passaram e obtive a porcaria desse erro que não se resolve nunca:`cd /home/vlucas/MEGA/Projetos/JPAHibernate-K19; JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 /usr/local/netbeans-8.1/java/maven/bin/mvn "-Dexec.args=-classpath %classpath br.com.K19.JPAHibernate.Dao.GeraTabelaTeste" -Dexec.executable=/usr/lib/jvm/java-8-openjdk-amd64/bin/java -Dexec.classpathScope=runtime org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...
Building k19_jpa 1.0-SNAPSHOT
The POM for unknown.binary:hibernate-jpamodelgen-4.3.1.Final:jar:SNAPSHOT is missing, no dependency information available
--- exec-maven-plugin:1.2.1:exec (default-cli) @ k19_jpa ---
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named k19_jpa
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at br.com.K19.JPAHibernate.Dao.GeraTabelaTeste.main(GeraTabelaTeste.java:8)
BUILD FAILURE
Total time: 2.135s
Finished at: Fri Sep 30 10:35:40 BRT 2016
Final Memory: 7M/147M
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project k19_jpa: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
`Esse é meu persistence.xml
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="k19_jpa" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>br.com.K19.JPAHibernate.Model.Editora</class> <properties> <!-- Drive do banco--> <!-- URL jdbc do banco--> <!-- Usuário do banco--> <!-- Senha do banco--> <!-- Dialeto que será usado pelo hibernate em tempo de execução. Neste caso como estamos usando o Mysql, logicamente o dialeto a ser usado é 'org.hibernate.dialect.MySQL5Dialect'. Se tiver necessidade de utilizar outro banco ou outra versão do mysql, substitua este dialeto por um mais adequado--> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/> <!-- Essa essa propriedade do hibernate tem como função [criar|atualizar|validar] a base de dados create => irá criar a base de dados caso a mesma não exista update => irá criar o base de dados caso a mesma não exista e irá refletir toda e qualquer atulização que for realizada no modelo validate => irá apenas validar a base de dados com o seu modelo mapeado, a mesma não executa nenhum timpo de alteração na base, apenas valida a mesma. Para produção é mais indicado utilizar 'validate'-->
A classe main
package br.com.K19.JPAHibernate.Dao; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; public class GeraTabelaTeste { public static void main(String[] args) { EntityManagerFactory factory = Persistence.createEntityManagerFactory("k19_jpa"); factory.close(); } } E o meu Bean package br.com.K19.JPAHibernate.Model; import java.io.Serializable; import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "k21_editora") public class Editora implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "editora_nome", nullable = false, length = 50) private String nome; @Column(name = "editora_email", nullable = false, length = 100) 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; } @Override public int hashCode() { int hash = 7; hash = 53 * hash + Objects.hashCode(this.id); return hash; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Editora other = (Editora) obj; if (!Objects.equals(this.id, other.id)) { return false; } return true; } }
Antes mesmo de perguntarem, sim meu persistence.xml está na pasta correta, com cerca de 200% de certeza absoluta.
Alguém pode por favor me dar uma luz. Estou para desistir.
Mensagens: 3
Participantes: 2