Java 类org.springframework.boot.autoconfigure.mongo.MongoProperties 实例源码

项目:spring5demo    文件:Spring5demoApplication.java   
@Bean
public CommandLineRunner runner(GitterProperties props, MongoProperties mongoProperties) {
    return args -> {
        context.registerBean(Mate.class, () -> new Mate("Lithium", "Alex", true));
        Mate mate = context.getBean(Mate.class);
        System.out.println("Mate from context: " + mate.nickname);
        System.out.println("Gitter Room: " + props.getRoom());

        Flux<Mate> people = Flux.just(
                new Mate("aliaksei-lithium", "Aliaksei"),
                new Mate("IRus", "Ruslan"),
                new Mate("bsiamionau", "Bahdan")
        );
        repository.deleteAll().thenMany(repository.save(people)).blockLast();
    };
}
项目:graylog-springboot    文件:MongoInstance.java   
public MongoInstance() throws IOException, InterruptedException {

        // Download Mongo artifacts into the project directory to ease cleanup
        IDownloadConfig downloadConfig = new DownloadConfigBuilder()
                .defaultsForCommand(Command.MongoD)
                .artifactStorePath(ARTIFACT_STORE_PATH)
                .build();

        // Extract Mongo artifacts into the project directory to ease cleanup
        IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
                .defaults(Command.MongoD)
                .artifactStore(new ExtractedArtifactStoreBuilder()
                        .defaults(Command.MongoD)
                        .download(downloadConfig)
                        .extractDir(EXTRACTED_STORE_PATH)
                )
                .build();

        // Store Mongo data into the project directory to ease cleanup
        Storage replication = new Storage("./data/mongodb/data", null, 0);

        MongodStarter starter = MongodStarter.getInstance(runtimeConfig);

        IMongodConfig mongodConfig = new MongodConfigBuilder()
                .version(Version.Main.PRODUCTION)
                .cmdOptions(new MongoCmdOptionsBuilder()
                        .useNoJournal(false)
                        .useSmallFiles(true)
                        .build())
                .net(new Net(MongoProperties.DEFAULT_PORT, Network.localhostIsIPv6()))
                .replication(replication)
                .build();

        mongo = starter.prepare(mongodConfig);
        process = mongo.start();
    }
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedMongoAutoConfiguration.java   
public EmbeddedMongoAutoConfiguration(MongoProperties properties,
        EmbeddedMongoProperties embeddedProperties, ApplicationContext context,
        IRuntimeConfig runtimeConfig) {
    this.properties = properties;
    this.embeddedProperties = embeddedProperties;
    this.context = context;
    this.runtimeConfig = runtimeConfig;
}
项目:spring-boot-concourse    文件:EmbeddedMongoAutoConfiguration.java   
public EmbeddedMongoAutoConfiguration(MongoProperties properties,
        EmbeddedMongoProperties embeddedProperties, ApplicationContext context,
        IRuntimeConfig runtimeConfig) {
    this.properties = properties;
    this.embeddedProperties = embeddedProperties;
    this.context = context;
    this.runtimeConfig = runtimeConfig;
}
项目:metadatamanagement    文件:MongoDbConfiguration.java   
/**
 * Constructor from {@link MongoAutoConfiguration}.
 */
@Autowired
public MongoDbConfiguration(MongoProperties properties,
    ObjectProvider<MongoClientOptions> options, Environment environment) {
  this.mongoProperties = properties;
  this.options = options.getIfAvailable();
  this.environment = environment;
}
项目:mongeez-spring-boot-starter    文件:MongeezAutoConfiguration.java   
private void copyMissingProperties(MongoProperties mongoProperties, MongeezProperties mongeezProperties) {
    if (StringUtils.isEmpty(mongeezProperties.getDatabase())) {
        mongeezProperties.setDatabase(mongoProperties.getMongoClientDatabase());
    }
    if (StringUtils.isEmpty(mongeezProperties.getAuthenticationDatabase())) {
        mongeezProperties.setAuthenticationDatabase(mongoProperties.getAuthenticationDatabase());
    }
    if (!mongeezProperties.hasCredentials() && hasCredentials(mongoProperties)) {
        // cannot copy credentials because Spring Data MongoDB clears the password after using it
        String msg = "Found credentials for Spring Data MongoDB but no credentials for Mongeez. " +
                "You need to define both for authentication to work.";
        throw new BeanCreationException(msg);
    }
}
项目:bluefairy    文件:ApplicationContext.java   
@Bean
@ConditionalOnProperty(value = APPLICATION_DATA_TYPE, havingValue = APPLICATION_DATA_TYPE_MONGO)
@Autowired
public MongoTemplate mongoTemplate(MongoProperties properties,
        @Value("${spring.data.mongodb.password}") String password) throws Exception {
    MongoClient client = new MongoClient(new ServerAddress(
        properties.getHost(), properties.getPort()));

    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(client, properties.getDatabase(),
        new UserCredentials(properties.getUsername(), password));

    return new MongoTemplate(mongoDbFactory);
}
项目:spring5demo    文件:MongoConfiguration.java   
@Autowired
public MongoConfiguration(MongoProperties mongoProperties) {
    this.mongoProperties = mongoProperties;
}
项目:canal-mongo    文件:MultipleMongoProperties.java   
public MongoProperties getNaive() {
    return naive;
}
项目:canal-mongo    文件:MultipleMongoProperties.java   
public void setNaive(MongoProperties naive) {
    this.naive = naive;
}
项目:canal-mongo    文件:MultipleMongoProperties.java   
public MongoProperties getComplete() {
    return complete;
}
项目:canal-mongo    文件:MultipleMongoProperties.java   
public void setComplete(MongoProperties complete) {
    this.complete = complete;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedMongoAutoConfiguration.java   
private int getPort() {
    if (this.properties.getPort() == null) {
        return MongoProperties.DEFAULT_PORT;
    }
    return this.properties.getPort();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MongoDataAutoConfiguration.java   
public MongoDataAutoConfiguration(ApplicationContext applicationContext,
        MongoProperties properties) {
    this.applicationContext = applicationContext;
    this.properties = properties;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MongoDataAutoConfiguration.java   
GridFsMongoDbFactory(MongoDbFactory mongoDbFactory, MongoProperties properties) {
    Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null");
    Assert.notNull(properties, "Properties must not be null");
    this.mongoDbFactory = mongoDbFactory;
    this.properties = properties;
}
项目:spring-boot-concourse    文件:EmbeddedMongoAutoConfiguration.java   
private int getPort() {
    if (this.properties.getPort() == null) {
        return MongoProperties.DEFAULT_PORT;
    }
    return this.properties.getPort();
}
项目:spring-boot-concourse    文件:MongoDataAutoConfiguration.java   
public MongoDataAutoConfiguration(MongoProperties properties, Environment environment,
        ResourceLoader resourceLoader) {
    this.properties = properties;
    this.environment = environment;
    this.resourceLoader = resourceLoader;
}
项目:spring-boot-concourse    文件:MongoDataAutoConfiguration.java   
GridFsMongoDbFactory(MongoDbFactory mongoDbFactory, MongoProperties properties) {
    Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null");
    Assert.notNull(properties, "Properties must not be null");
    this.mongoDbFactory = mongoDbFactory;
    this.properties = properties;
}
项目:contestparser    文件:EmbeddedMongoAutoConfiguration.java   
private int getPort() {
    if (this.properties.getPort() == null) {
        return MongoProperties.DEFAULT_PORT;
    }
    return this.properties.getPort();
}
项目:contestparser    文件:MongoDataAutoConfiguration.java   
GridFsMongoDbFactory(MongoDbFactory mongoDbFactory, MongoProperties properties) {
    Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null");
    Assert.notNull(properties, "Properties must not be null");
    this.mongoDbFactory = mongoDbFactory;
    this.properties = properties;
}
项目:mongeez-spring-boot-starter    文件:MongeezAutoConfiguration.java   
private boolean hasCredentials(MongoProperties properties) {
    return properties.getUsername() != null && properties.getPassword() != null;
}
项目:mandrel    文件:MongoServiceTest.java   
@Before
public void beforeEachTest() {

    CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(),
            CodecRegistries.fromCodecs(new LocalDateTimeCodec(), new HostAndPortCodec(), new LocalDateTimeCodec()));

    MongoProperties properties = new MongoProperties();

    MongoClient mongoClient = new MongoClient(new MongoClientURI(properties.getUri(), MongoClientOptions.builder().codecRegistry(codecRegistry)));

    mongoMetricsRepository = new MongoMetricsRepository(mongoClient, properties, new ObjectMapper());

    mongoMetricsRepository.init();

    metricsService = new MetricsService(mongoMetricsRepository);

}
项目:mandrel    文件:MongoMetricsRepositoryTest.java   
@Before
public void beforeEachTest() {

    CodecRegistry codecRegistry = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(),
            CodecRegistries.fromCodecs(new LocalDateTimeCodec(), new HostAndPortCodec(), new LocalDateTimeCodec()));

    MongoProperties properties = new MongoProperties();

    MongoClient mongoClient = new MongoClient(new MongoClientURI(properties.getUri(), MongoClientOptions.builder().codecRegistry(codecRegistry)));

    mongoMetricsRepository = new MongoMetricsRepository(mongoClient, properties, new ObjectMapper());

    mongoMetricsRepository.init();

}