我在Windows本地主机上成功运行了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"/>
最佳答案
在您的休眠配置文件中将休眠属性hbm2ddl.auto设置为“创建”。
关于hibernate - Grails/Hibernate不会在MySQL Linux上自动创建表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13670959/