我之前在 Windows 上运行 MongoDb,我的 Java 应用程序连接完美。现在我将 MongoDb 切换到 Linux,并以“./mongod”开始。但是每当我尝试连接到 Mongo 时,都会出现以下异常。
Caused by: com.mongodb.MongoException: can't find a master
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:434)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:209)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
at com.mongodb.DBCollection.findOne(DBCollection.java:647)
at com.mongodb.DBCollection.findOne(DBCollection.java:626)
at com.mongodb.DBApiLayer$MyCollection.createIndex(DBApiLayer.java:364)
at com.mongodb.DBCollection.createIndex(DBCollection.java:436)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:515)
at com.google.code.morphia.DatastoreImpl.ensureIndex(DatastoreImpl.java:245)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:310)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:279)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:340)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:333)