認証を使用してMongoDBに接続しようとしています。私はMongoサーバーでこれを行いました:
use admin
db.addUser('adminLogin','adminPassword')
db.shutdownServer()
exit
その後、サーバーを再起動して発行しましたmongod --auth
DataSource.groovyでdb構成を次のように設定します。
grails {
mongo {
host = "localhost"
port = 27017
username = "adminLogin"
password = "adminPassword"
databaseName = "my DB name"
options {
autoConnectRetry = true
connectTimeout = 300
}
}
}
アプリケーションを起動すると、次のエラーメッセージが表示されます。
ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean
with name 'mongoDatastore': FactoryBean threw exception on object creation; nested
exception is org.springframework.data.mongodb.CannotGetMongoDbConnectionException:
Failed to authenticate to database
どんな提案でも大歓迎です。前もって感謝します。