2017-07-28 42 views
0

我創建蒙戈3.4.6與碼頭工人:石英MongoDB的命令失敗,出現錯誤13:「沒有被授權就quartz_jobs_test執行命令

這是我的用戶:

mongo> Successfully added user: { 
mongo> "user" : "admin", 
mongo> "roles" : [ 
mongo> { 
mongo> "role" : "root", 
mongo> "db" : "admin" 
mongo> } 
mongo> ] 
mongo> } 

我想從[類路徑資源[quartz.properties]裝入石英配置(從MongoDB的石英招聘商店https://github.com/michaelklishin/quartz-mongodb

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
# Quartz Job Scheduling 
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

#org.quartz.scheduler.instanceName=springboot-quartz-mongodb 
#org.quartz.scheduler.instanceId=AUTO 

# Use the MongoDB store 
org.quartz.jobStore.class=com.novemberain.quartz.mongodb.MongoDBJobStore 

# MongoDB URI (optional if 'org.quartz.jobStore.addresses' is set) 
org.quartz.jobStore.mongoUri=mongodb://localhost:27018 
org.quartz.jobStore.username=admin 
org.quartz.jobStore.password=password 

# MongoDB Database name 
org.quartz.jobStore.authDbName=admin 
org.quartz.jobStore.dbName=quartz_jobs_test 

# Will be used to create collections like quartz_jobs, quartz_triggers, quartz_calendars, quartz_locks 
org.quartz.jobStore.collectionPrefix=quartz_ 

# Thread count setting is ignored by the MongoDB store but Quartz requires it 
org.quartz.threadPool.threadCount=1 

# Skip running a web request to determine if there is an updated version of Quartz available for download 
org.quartz.scheduler.skipUpdateCheck=true 

# Register Quartz plugins to be executed 
org.quartz.plugin.triggerHistory.class=org.quartz.plugins.history.LoggingTriggerHistoryPlugin 

現在我的應用程序將失敗,以下情況除外:

Caused by: com.mongodb.MongoCommandException: Command failed with error 13: 'not authorized on quartz_jobs_test to execute command { createIndexes: "quartz__jobs", indexes: [ { key: { keyGroup: 1, keyName: 1 }, name: "keyGroup_1_keyName_1", ns: "quartz_jobs_test.quartz__jobs", unique: true } ] }' on server localhost:27018. The full response is { "ok" : 0.0, "errmsg" : "not authorized on quartz_jobs_test to execute command { createIndexes: \"quartz__jobs\", indexes: [ { key: { keyGroup: 1, keyName: 1 }, name: \"keyGroup_1_keyName_1\", ns: \"quartz_jobs_test.quartz__jobs\", unique: true } ] }", "code" : 13, "codeName" : "Unauthorized" } 
    at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:115) 
    at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:114) 
    at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:168) 
    at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:289) 
    at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:176) 
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:216) 
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:207) 
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:146) 
    at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:139) 
    at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:150) 
    at com.mongodb.operation.CreateIndexesOperation$1.call(CreateIndexesOperation.java:144) 
    at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:422) 
    at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:413) 
    at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:144) 
    at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:71) 
    at com.mongodb.Mongo.execute(Mongo.java:845) 
    at com.mongodb.Mongo$2.execute(Mongo.java:828) 
    at com.mongodb.MongoCollectionImpl.createIndexes(MongoCollectionImpl.java:491) 
    at com.mongodb.MongoCollectionImpl.createIndex(MongoCollectionImpl.java:458) 
    at com.novemberain.quartz.mongodb.dao.JobDao.createIndex(JobDao.java:49) 
    at com.novemberain.quartz.mongodb.MongoDBJobStore.ensureIndexes(MongoDBJobStore.java:500) 
    ... 60 common frames omitted 

我在做什麼錯,怎麼解決?

回答

0

問題同org.quartz.jobStore.mongoUri因爲當這個屬性存在,下面沒有考慮到:

org.quartz.jobStore.username=admin 
org.quartz.jobStore.password=password 

所以你必須移動用戶名/密碼爲org.quartz.jobStore.mongoUri屬性,如:

org.quartz.jobStore.mongoUri=mongodb://admin:[email protected]:27018 

這就是它