2014-10-16 21 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