Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails/Hibernate不会在MySQL Linux上自动创建表_Hibernate_Grails - Fatal编程技术网

Grails/Hibernate不会在MySQL Linux上自动创建表

Grails/Hibernate不会在MySQL Linux上自动创建表,hibernate,grails,Hibernate,Grails,我在Windows localhost上成功运行了Grails应用程序。然后我将war部署到Linux上。除了Hibernate(我相信)不希望在那里创建任何表之外,整个应用程序都正常工作: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; ... Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntax

我在Windows localhost上成功运行了Grails应用程序。然后我将war部署到Linux上。除了Hibernate(我相信)不希望在那里创建任何表之外,整个应用程序都正常工作:

org.springframework.dao.InvalidDataAccessResourceUsageException:
   could not execute query;
   ...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
   Table 'xxx.yyy' doesn't exist
   ...
(no other errors noticed)
一旦我手动创建了所有表,应用程序就可以正常工作了

问题是如何使表格自动创建?就像它应该做的那样

本地MySQL:

MySQL Ver 14.14 Distrib 5.5.28, for Win64 (x86)
服务器的MySQL:

mysql  Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64) using readline 6.2
文件
/etc/tomcat7/context.xml

    <Resource name="jdbc/XXX" auth="Container"
          type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:3306/xxx"
          username="xxx" password="xxx" maxActive="20" maxIdle="10"
          removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"
          maxWait="-1"/>


在您的hibernate配置文件中将hibernate属性hbm2ddl.auto设置为“create”。

在DataSources.groovy中设置
hbm2ddl.auto
(拼写!)对我很有帮助。谢谢看起来不同的环境对此参数有不同的默认值。