2016-05-12 16 views
1

私はいくつかのエディションを試しましたが使用しませんでした。私はプロジェクトを続けるためにこの部分を解決する必要があります。
ハイバネートがデータベースにテーブルを生成していないため、エラーのある場所が見つかりません。Hibernateはhibernate.hbm2ddl.auto = createにもかかわらずテーブルを作成しません

コードは:

package br.com.evolutionary.modelo; 

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

@Entity 
public class Pokemon { 

    @Id 
    @GeneratedValue 
    private Long id; 

    @Column 
    private String nome; 

    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; 
    } 

} 

持続性である:

<persistence 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" 
version="2.0"> 
<persistence-unit name="evolutionary" 
    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:3306/evolutionary" /> 
     <property name="hibernate.connection.driver" value="com.mysql.jdbc.Driver" /> 
     <property name="hibernate.connection.username" value="root" /> 
     <property name="hibernate.connection.password" value="12345" /> 
     <property name="hibernate.show_sql" value="true" /> 
     <property name="hibernate.format_sql" value="true" /> 
     <property name="hibernate.hbm2ddl.auto" value="update" /> 
    </properties> 
</persistence-unit> 

の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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>br.com</groupId> 
    <artifactId>evolutionary</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <dependencies> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>6.0.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>5.1.0.Final</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.6</version> 
       <configuration> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

出力ログTomcatがある:

mai 12, 2016 7:30:03 AM org.apache.tomcat.util.digester.SetPropertiesRule begin 
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:evolutionary' did not find a matching property. 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Server version:  Apache Tomcat/8.0.33 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Server built:   Mar 18 2016 20:31:49 UTC 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Server number:   8.0.33.0 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: OS Name:    Linux 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: OS Version:   4.4.0-21-generic 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Architecture:   amd64 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Java Home:    /usr/lib/jvm/java-8-openjdk-amd64/jre 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: JVM Version:   1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: JVM Vendor:   Oracle Corporation 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: CATALINA_BASE:   /home/douglas/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: CATALINA_HOME:   /opt/apache-tomcat-8.0.33 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dcatalina.base=/home/douglas/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dcatalina.home=/opt/apache-tomcat-8.0.33 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dwtp.deploy=/home/douglas/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=/opt/apache-tomcat-8.0.33/endorsed 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dfile.encoding=UTF-8 
mai 12, 2016 7:30:03 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent 
INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib 
mai 12, 2016 7:30:03 AM org.apache.coyote.AbstractProtocol init 
INFORMAÇÕES: Initializing ProtocolHandler ["http-nio-8080"] 
mai 12, 2016 7:30:03 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 
INFORMAÇÕES: Using a shared selector for servlet write/read 
mai 12, 2016 7:30:03 AM org.apache.coyote.AbstractProtocol init 
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-nio-8009"] 
mai 12, 2016 7:30:03 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 
INFORMAÇÕES: Using a shared selector for servlet write/read 
mai 12, 2016 7:30:03 AM org.apache.catalina.startup.Catalina load 
INFORMAÇÕES: Initialization processed in 623 ms 
mai 12, 2016 7:30:03 AM org.apache.catalina.core.StandardService startInternal 
INFORMAÇÕES: Starting service Catalina 
mai 12, 2016 7:30:03 AM org.apache.catalina.core.StandardEngine startInternal 
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/8.0.33 
mai 12, 2016 7:30:06 AM org.apache.jasper.servlet.TldScanner scanJars 
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 
mai 12, 2016 7:30:06 AM com.sun.faces.config.ConfigureListener contextInitialized 
INFORMAÇÕES: Inicializando Mojarra 2.2.13 (20160203-1910 unable to get svn info) para o contexto '/evolutionary' 
mai 12, 2016 7:30:06 AM com.sun.faces.spi.InjectionProviderFactory createInstance 
INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes. Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas. 
mai 12, 2016 7:30:07 AM org.primefaces.webapp.PostConstructApplicationEventListener processEvent 
INFORMAÇÕES: Running on PrimeFaces 5.3 
mai 12, 2016 7:30:07 AM org.apache.coyote.AbstractProtocol start 
INFORMAÇÕES: Starting ProtocolHandler ["http-nio-8080"] 
mai 12, 2016 7:30:07 AM org.apache.coyote.AbstractProtocol start 
INFORMAÇÕES: Starting ProtocolHandler ["ajp-nio-8009"] 
mai 12, 2016 7:30:07 AM org.apache.catalina.startup.Catalina start 
INFORMAÇÕES: Server startup in 4132 ms 

誰でも手助けできますか?

+0

を、私はそれを作成すると? – Douglas

+0

申し訳ありませんが、セッションファクトリーではなくJPAを使用しています:)そして、あなたが提供するログには、Hibernateブートストラップに関する情報はありません。 –

答えて

0

persistence.xmlがMeta-INFフォルダに存在するかどうかを確認してください。

私の推測では、Persistence.xmlはアプリケーションの起動時にロードされていないと思います。

また、コードにPersistence.createEntityManagerFactory(persistantUnitName)を呼び出すかどうかを確認してください。

以下の構成とブートストラップ上のアイデアを取得するためにHibernate EntityManagerのドキュメントをご覧ください:私はこのコードを持っているv.ladynev @

https://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html/configuration.html

+0

私はまだできませんでした。 – Douglas

関連する問題