Package org.springframework.data.mongodb.core

Examples of org.springframework.data.mongodb.core.SimpleMongoDbFactory


    Validate.notNull(uri, "The mongo database uri is required.");
    Validate.notNull(mongo, "The mongo database connection is required.");
    String username = uri.getUsername();
    char[] password = uri.getPassword();
    if (Strings.isNullOrEmpty(username)) {
      return new SimpleMongoDbFactory(mongo, uri.getDatabase());
    }
    return new SimpleMongoDbFactory(mongo, uri.getDatabase(),
        new UserCredentials(username, password == null ? null
            : String.valueOf(password)));
  }
View Full Code Here


                MONGO_MAP.put(mongoUri, mongo);

            }

            MongoURI uri = new MongoURI(mongoUri);
            return new MongoTemplate(new SimpleMongoDbFactory(mongo, uri.getDatabase(),
                    new UserCredentials(uri.getUsername(), parseChars(uri.getPassword()))));

        } catch (Exception e) {
            logger.error("mongo db error ,uri={}", mongoUri, e);
            return null;
View Full Code Here

    int port = 27017;
    String dbname = "rnd_spring_boot";
   
    // Create MongoTemplate
    MongoClient client = new MongoClient(host, port);
    MongoDbFactory factory = new SimpleMongoDbFactory(client, dbname);
    MongoTemplate template = new MongoTemplate(factory);
   
    return template;
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.SimpleMongoDbFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.