grails中的异常dbm-update - NoSuchBeanDefinitionException

时间:2014-10-16 22:24:01

标签: grails groovy data-migration

当我运行"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)

它适用于默认的dataSource(如果我运行" grails dbm-update"),但不适用于生产或我的自定义数据源。

我使用Grails 2.4.3和数据库迁移:1.4.0。 我在Amazon AWS上运行它 - RDS MySql DB。

这是我的dataSource:

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
      }          
   }
}

1 个答案:

答案 0 :(得分:1)

您所指的项目production不是数据源,而是production环境中常规数据源的配置。所以这个电话应该有效:

grails prod dbm-update