Hibernate没有创建表并取消部署我的应用程序

时间:2014-07-20 10:07:53

标签: hibernate maven jpa jboss persistence.xml

我正在使用Hibernate在maven JBoss项目中自动创建mysql表。 当我部署时,我得到这个信息msg:

13:48:24,415 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-7) HHH000206: hibernate.properties not found

并出现此错误:

13:50:44,880 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'mydb.my_table' doesn't exist

我在persistence.xml中包含了这些属性:

 <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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">
 <persistence-unit name="primary">
  <!-- If you are running in a production environment, add a managed 
     data source, the example data source is just for development and testing! -->
        <jta-data-source>java:jboss/datasources/mydb</jta-data-source>
  <properties>
     <!-- Properties for Hibernate -->
 <property name="hibernate.hbm2ddl.auto" value="create" />   
 <property name="hibernate.show_sql" value="true" />
  </properties>
</persistence-unit>
</persistence>

和pom.xml中的相应依赖项:

hibernate-validator,hibernate-jpamodelgen,hibernate-validator-annotation-processor,hibernate-entitymanager和mysql-connector-java

但永远不会创建表格。我该怎么办?

0 个答案:

没有答案