【发布时间】:2014-10-17 15:56:55
【问题描述】:
当我运行"grails dbm-update --dataSource=production" 时,出现以下异常:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory_production' is defined
at grails.plugin.databasemigration.MigrationUtils.findSessionFactory(MigrationUtils.groovy:142)
at grails.plugin.databasemigration.MigrationUtils.getDatabase(MigrationUtils.groovy:105)
at _DatabaseMigrationCommon_groovy$_run_closure2_closure11.doCall(_DatabaseMigrationCommon_groovy:52)
at grails.plugin.databasemigration.MigrationUtils.executeInSession(MigrationUtils.groovy:133)
at _DatabaseMigrationCommon_groovy$_run_closure2.doCall(_DatabaseMigrationCommon_groovy:51)
at DbmUpdate$_run_closure1.doCall(DbmUpdate:25)
它适用于默认数据源(如果我运行“grails dbm-update”),但不适用于生产或我的自定义数据源。
我使用 Grails 2.4.3 和 database-migration:1.4.0。 我在 Amazon AWS - RDS MySql DB 上运行它。
这是我的数据源:
production {
grails.dbconsole.enabled = true
dataSource {
grails.dbconsole.enabled = true
username = "myusername"
password = "mypassword"
pooled = true
dbCreate = "none"
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://mydatabase.us-west-1.rds.amazonaws.com:3306/ebdb?autoReconnect=true" dialect = org.hibernate.dialect.MySQL5InnoDBDialect
properties {
validationQuery = "SELECT 1"
testOnBorrow = true
testOnReturn = true
testWhileIdle = true
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 3
minEvictableIdleTimeMillis = 1800000
}
}
}
【问题讨论】:
-
我曾经在 Windows 上的不同控制台(cmd 或 powershell)上遇到过奇怪的问题。它只适用于 cmd。但您也可以使用DBM Docu 中的通知。在那里你必须引用参数
-
可能只是复制粘贴错误,但是方言真的和url在同一行吗?
标签: grails groovy data-migration