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

Spring5demoApplication.java 文件源码 项目:spring5demo 阅读 37 收藏 0 点赞 0 评论 0
@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();
    };
}
MongoInstance.java 文件源码 项目:graylog-springboot 阅读 35 收藏 0 点赞 0 评论 0
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();
    }
EmbeddedMongoAutoConfiguration.java 文件源码 项目:https-github.com-g0t4-jenkins2-course-spring-boot 阅读 33 收藏 0 点赞 0 评论 0
public EmbeddedMongoAutoConfiguration(MongoProperties properties,
        EmbeddedMongoProperties embeddedProperties, ApplicationContext context,
        IRuntimeConfig runtimeConfig) {
    this.properties = properties;
    this.embeddedProperties = embeddedProperties;
    this.context = context;
    this.runtimeConfig = runtimeConfig;
}
EmbeddedMongoAutoConfiguration.java 文件源码 项目:spring-boot-concourse 阅读 32 收藏 0 点赞 0 评论 0
public EmbeddedMongoAutoConfiguration(MongoProperties properties,
        EmbeddedMongoProperties embeddedProperties, ApplicationContext context,
        IRuntimeConfig runtimeConfig) {
    this.properties = properties;
    this.embeddedProperties = embeddedProperties;
    this.context = context;
    this.runtimeConfig = runtimeConfig;
}
MongoDbConfiguration.java 文件源码 项目:metadatamanagement 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Constructor from {@link MongoAutoConfiguration}.
 */
@Autowired
public MongoDbConfiguration(MongoProperties properties,
    ObjectProvider<MongoClientOptions> options, Environment environment) {
  this.mongoProperties = properties;
  this.options = options.getIfAvailable();
  this.environment = environment;
}
MongeezAutoConfiguration.java 文件源码 项目:mongeez-spring-boot-starter 阅读 35 收藏 0 点赞 0 评论 0
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);
    }
}
ApplicationContext.java 文件源码 项目:bluefairy 阅读 38 收藏 0 点赞 0 评论 0
@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);
}
MongoConfiguration.java 文件源码 项目:spring5demo 阅读 45 收藏 0 点赞 0 评论 0
@Autowired
public MongoConfiguration(MongoProperties mongoProperties) {
    this.mongoProperties = mongoProperties;
}
MultipleMongoProperties.java 文件源码 项目:canal-mongo 阅读 38 收藏 0 点赞 0 评论 0
public MongoProperties getNaive() {
    return naive;
}
MultipleMongoProperties.java 文件源码 项目:canal-mongo 阅读 39 收藏 0 点赞 0 评论 0
public void setNaive(MongoProperties naive) {
    this.naive = naive;
}
MultipleMongoProperties.java 文件源码 项目:canal-mongo 阅读 36 收藏 0 点赞 0 评论 0
public MongoProperties getComplete() {
    return complete;
}
MultipleMongoProperties.java 文件源码 项目:canal-mongo 阅读 31 收藏 0 点赞 0 评论 0
public void setComplete(MongoProperties complete) {
    this.complete = complete;
}
EmbeddedMongoAutoConfiguration.java 文件源码 项目:https-github.com-g0t4-jenkins2-course-spring-boot 阅读 36 收藏 0 点赞 0 评论 0
private int getPort() {
    if (this.properties.getPort() == null) {
        return MongoProperties.DEFAULT_PORT;
    }
    return this.properties.getPort();
}
MongoDataAutoConfiguration.java 文件源码 项目:https-github.com-g0t4-jenkins2-course-spring-boot 阅读 33 收藏 0 点赞 0 评论 0
public MongoDataAutoConfiguration(ApplicationContext applicationContext,
        MongoProperties properties) {
    this.applicationContext = applicationContext;
    this.properties = properties;
}
MongoDataAutoConfiguration.java 文件源码 项目:https-github.com-g0t4-jenkins2-course-spring-boot 阅读 36 收藏 0 点赞 0 评论 0
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;
}
EmbeddedMongoAutoConfiguration.java 文件源码 项目:spring-boot-concourse 阅读 37 收藏 0 点赞 0 评论 0
private int getPort() {
    if (this.properties.getPort() == null) {
        return MongoProperties.DEFAULT_PORT;
    }
    return this.properties.getPort();
}
MongoDataAutoConfiguration.java 文件源码 项目:spring-boot-concourse 阅读 37 收藏 0 点赞 0 评论 0
public MongoDataAutoConfiguration(MongoProperties properties, Environment environment,
        ResourceLoader resourceLoader) {
    this.properties = properties;
    this.environment = environment;
    this.resourceLoader = resourceLoader;
}
MongoDataAutoConfiguration.java 文件源码 项目:spring-boot-concourse 阅读 33 收藏 0 点赞 0 评论 0
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;
}
EmbeddedMongoAutoConfiguration.java 文件源码 项目:contestparser 阅读 33 收藏 0 点赞 0 评论 0
private int getPort() {
    if (this.properties.getPort() == null) {
        return MongoProperties.DEFAULT_PORT;
    }
    return this.properties.getPort();
}
MongoDataAutoConfiguration.java 文件源码 项目:contestparser 阅读 37 收藏 0 点赞 0 评论 0
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;
}
MongeezAutoConfiguration.java 文件源码 项目:mongeez-spring-boot-starter 阅读 30 收藏 0 点赞 0 评论 0
private boolean hasCredentials(MongoProperties properties) {
    return properties.getUsername() != null && properties.getPassword() != null;
}
MongoServiceTest.java 文件源码 项目:mandrel 阅读 35 收藏 0 点赞 0 评论 0
@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);

}
MongoMetricsRepositoryTest.java 文件源码 项目:mandrel 阅读 34 收藏 0 点赞 0 评论 0
@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();

}


问题


面经


文章

微信
公众号

扫码关注公众号