2014-10-16 50 views
0

当我运行"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 
     }   
    } 
} 
+0

我曾经有不同的控制台在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

+0

也许只是一个复制和粘贴错误,但方言真的和url一样吗? – cfrick 2014-10-17 07:45:38

回答

1

你指的是production不是一个数据源,但在production环境的常规数据源的配置项。所以这个电话应该工作:

grails prod dbm-update 
+0

自定义环境如何?我必须使用“grails -Dgrails.env = mycustomenv dbm-update”? – chenk 2014-10-18 00:39:32

+0

@ user2153912我不能说经验,但我认为这是有效的,因为env很早就处理完毕,dev/test/prod只是最常见情况下的一些快捷方式。所以它适用于prod而不是你的env?错误? – cfrick 2014-10-18 08:54:26

+0

是的,它也适用于自定义环境。谢谢。 – chenk 2014-10-18 21:25:16