Grails 3.4.0上MongoDB GORM插件的安装问题

时间:2014-01-22 10:09:21

标签: mongodb grails gorm grails-plugin

我的项目工作正常。我尝试通过GGTS IDE中的Open grails插件管理器安装MongoDB插件。

现在我在运行项目后遇到以下错误。 一些信息 - 我的MongoDB当前版本是v2.4.8。我正在安装此插件。http://grails.org/plugin/mongodb

Configuring Spring Security Core ...
... finished configuring Spring Security Core
Configuring Spring Security Facebook ...
... finished configuring Spring Security Facebook
2014-01-22 01:28:16,788 [localhost-startStop-1] WARN  hibernate.AbstractEhcacheRegionFactory  - Couldn't find a specific ehcache configuration for cache named [com.lyfe.sec.Authority]; using defaults.
| Error 2014-01-22 01:28:18,524 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'mongoDatastore': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Database name must only contain letters, numbers, underscores and dashes!
Message: Error creating bean with name 'mongoDatastore': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Database name must only contain letters, numbers, underscores and dashes!
   Line | Method
->> 109 | postProcessBeanFactory in org.grails.datastore.gorm.plugin.support.PersistenceContextInterceptorAggregator
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   303 | innerRun               in java.util.concurrent.FutureTask$Sync
|   138 | run . . . . . . . . .  in java.util.concurrent.FutureTask
|   895 | runTask                in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run . . . . . . . . .  in     ''
^   695 | run                    in java.lang.Thread
**Caused by IllegalArgumentException: Database name must only contain letters, numbers, underscores and dashes!**
->> 253 | createMongoTemplate    in org.grails.datastore.mapping.mongo.MongoDatastore
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   222 | afterPropertiesSet     in     ''
|    53 | getObject . . . . . .  in org.grails.datastore.gorm.mongo.bean.factory.MongoDatastoreFactoryBean
|   109 | postProcessBeanFactory in org.grails.datastore.gorm.plugin.support.PersistenceContextInterceptorAggregator
|   303 | innerRun . . . . . . . in java.util.concurrent.FutureTask$Sync
|   138 | run                    in java.util.concurrent.FutureTask
|   895 | runTask . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run                    in     ''
^   695 | run . . . . . . . . .  in java.lang.Thread

2 个答案:

答案 0 :(得分:0)

当然,我想你会说Grails 2.4.0。好的这是我的mongodb的DataSource.groovy:

environments {
    development {
    grails {
        mongo {
            host = "10.0.11.243"
            port = 27017
            username = "username"
            password = "userpassword"
            databaseName = "yourdb"
            options {
                autoConnectRetry = true
                connectTimeout = 300
            }
        }
    }
}
}

您必须在mongo中创建一个数据库,并且该用户可以访问它。

答案 1 :(得分:0)

您对数据库使用了什么名称?请注意错误中的以下行:

Message: Error creating bean with name 'mongoDatastore': 
FactoryBean threw exception on object creation; nested exception is 
java.lang.IllegalArgumentException: **Database name** must only contain letters, numbers, underscores and dashes!

在配置中的某个位置,您输入了无效的数据库名称或根本没有设置一个。检查DataSource.groovy中的值。