SpringMongoConfig.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:kanbanboard 作者:
@Override
public Mongo mongo() throws Exception {
    if(!authenticate) {
        //Allows testing with a database without users and authentication configured.
        //should not be used in production.
        log.warn("MongoDB is accessed without any authentication. " +
                "This is strongly discouraged and should only be used in a testing environment.");
        return new MongoClient(hostname);
    } else {
        List<MongoCredential> cred = new LinkedList<>();
        cred.add(MongoCredential.createCredential(dbUserName, dbAuthDB, dbPasswd.toCharArray()));
        ServerAddress addr = new ServerAddress(hostname, dbPort);
        return new MongoClient(addr, cred);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号