Search in sources :

Example 1 with Mongobee

use of com.github.mongobee.Mongobee in project jhipster-sample-app-mongodb by jhipster.

the class CloudDatabaseConfiguration method mongobee.

@Bean
public Mongobee mongobee(MongoDbFactory mongoDbFactory, MongoTemplate mongoTemplate, Cloud cloud) {
    log.debug("Configuring Cloud Mongobee");
    List<ServiceInfo> matchingServiceInfos = cloud.getServiceInfos(MongoDbFactory.class);
    if (matchingServiceInfos.size() != 1) {
        throw new CloudException("No unique service matching MongoDbFactory found. Expected 1, found " + matchingServiceInfos.size());
    }
    MongoServiceInfo info = (MongoServiceInfo) matchingServiceInfos.get(0);
    Mongobee mongobee = new Mongobee(info.getUri());
    mongobee.setDbName(mongoDbFactory.getDb().getName());
    mongobee.setMongoTemplate(mongoTemplate);
    // package to scan for migrations
    mongobee.setChangeLogsScanPackage("io.github.jhipster.sample.config.dbmigrations");
    mongobee.setEnabled(true);
    return mongobee;
}
Also used : ServiceInfo(org.springframework.cloud.service.ServiceInfo) MongoServiceInfo(org.springframework.cloud.service.common.MongoServiceInfo) CloudException(org.springframework.cloud.CloudException) Mongobee(com.github.mongobee.Mongobee) MongoServiceInfo(org.springframework.cloud.service.common.MongoServiceInfo) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 2 with Mongobee

use of com.github.mongobee.Mongobee in project jhipster-sample-app-mongodb by jhipster.

the class DatabaseConfiguration method mongobee.

@Bean
public Mongobee mongobee(MongoClient mongoClient, MongoTemplate mongoTemplate, MongoProperties mongoProperties) {
    log.debug("Configuring Mongobee");
    Mongobee mongobee = new Mongobee(mongoClient);
    mongobee.setDbName(mongoProperties.getDatabase());
    mongobee.setMongoTemplate(mongoTemplate);
    // package to scan for migrations
    mongobee.setChangeLogsScanPackage("io.github.jhipster.sample.config.dbmigrations");
    mongobee.setEnabled(true);
    return mongobee;
}
Also used : Mongobee(com.github.mongobee.Mongobee) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Aggregations

Mongobee (com.github.mongobee.Mongobee)2 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)2 CloudException (org.springframework.cloud.CloudException)1 ServiceInfo (org.springframework.cloud.service.ServiceInfo)1 MongoServiceInfo (org.springframework.cloud.service.common.MongoServiceInfo)1 Bean (org.springframework.context.annotation.Bean)1