当我运行"grails dbm-update --dataSource=production"
我得到以下异常:异常Grails的DBM更新 - NoSuchBeanDefinitionException
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更新”),但不在生产上或在我的自定义数据源上工作。
我使用Grails 2.4.3和数据库迁移: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]中使用此通知(http://grails-plugins.github.io/grails-database-migration/docs/manual/ref/Update%20Scripts/dbm-update.html)。在那里你必须引用参数 – matcauthon 2014-10-17 07:04:07
也许只是一个复制和粘贴错误,但方言真的和url一样吗? – cfrick 2014-10-17 07:45:38