Criar tabelas automaticamente no banco quando subir wildfly
03/06/2016
0
Pessoal, quero que as tabelas sejam criadas automaticamente quando subir o servidor web (wildfly) porém isso não acontece, alguém pode ajudar? Abaixo deixo os códigos:
persistence.xml:
A classe HibernateUtil:
Não acontece nada, alguém pode ajudar?
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="pokemax" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost/pokemax" /> <property name="hibernate.connection.driver" value="com.mysql.jdbc.Driver" /> <property name="hibernate.connection.username" value="pokemax" /> <property name="hibernate.connection.password" value="pokemax2" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> </properties> </persistence-unit> </persistence>
A classe HibernateUtil:
package br.com.pokemax.util; import java.util.logging.Logger; import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; public class HibernateUtil { @Produces @PersistenceContext private EntityManager em; @Produces public Logger produceLog(InjectionPoint injectionPoint) { return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); } }
Não acontece nada, alguém pode ajudar?
Douglas
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)