如果数据库不存在,请配置grails以创建数据库。 [英] configure grails to create the database if it doesn't exist.
问题描述
dataSource {
pooled = true
driverClassName =com.mysql.jdbc.Driver
dialect =org.hibernate.dialect.MySQL5InnoDBDialect
username =sa
password =
}
environments {
development {
dataSource {
dbCreate =create-drop// //'create','create-drop','update'之一'validate',''
url =jdbc:mysql:// localhost / myapp?useUnicode = yes& zeroDateTimeBehavior = convertToNull& characterEncoding = UTF-8
username =root
密码=
}
}
}
运行我的应用程序失败,出现错误:创建名为'transactionManagerPostProcessor'的bean时出错:
当我手动去我的数据库并创建一个名为 myapp
的数据库
我认为dbCreate中的 create-drop
设置是假设它创建的数据库不存在。
问题 如何配置设置以便创建数据库当它不存在于MySQL中时 创建数据库本身是不切实际的,因为它非常适合供应商,比DDL创建表,序列等你经常需要指定访问规则,存储选项等。 Hibernate会生成并运行schama DDL,但是你有通过创建数据库本身来启动进程,除了简单的数据库(如H2)。 I have the following settings on a new grails project: when I run my app it fails with an error: This error goes away when I manually go to my database and create a database called I thought the Question How can I configure the settings so that the database gets created when it does not exist in the MySQL Creating the database itself is impractical because it is very vendor-specific, even more so than the DDL to create tables, sequences, etc. You often need to specify access rules, storage options, etc. Hibernate will generate and run the schama DDL but you have to start the process by creating the database itself except for simple databases like H2. 这篇关于如果数据库不存在,请配置grails以创建数据库。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
username = "sa"
password = ""
}
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost/myapp?useUnicode=yes&zeroDateTimeBehavior=convertToNull&characterEncoding=UTF-8"
username = "root"
password = ""
}
}
}
Error creating bean with name 'transactionManagerPostProcessor':
myapp
create-drop
setting in dbCreate is suppose to create the db if it does not exist.