This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: disable automatic db migration from Mongobee
This is due to Mongobee having a bug that prevents it from working with Mongo Atlas correctly; jhipster/generator-jhipster#8665
- Loading branch information
1 parent
46b436d
commit 9b2a43c
Showing
3 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/com/openarchitex/accotech/config/DatabaseConfiguration.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.openarchitex.accotech.config; | ||
|
||
import io.github.jhipster.config.JHipsterConstants; | ||
import com.github.mongobee.Mongobee; | ||
import com.mongodb.MongoClient; | ||
import io.github.jhipster.domain.util.JSR310DateConverters.DateToZonedDateTimeConverter; | ||
import io.github.jhipster.domain.util.JSR310DateConverters.ZonedDateTimeToDateConverter; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.mongo.MongoProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.data.mongodb.config.EnableMongoAuditing; | ||
import org.springframework.data.mongodb.core.MongoTemplate; | ||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions; | ||
import org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener; | ||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; | ||
|
||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Configuration | ||
@EnableMongoRepositories("com.openarchitex.accotech.repository") | ||
@Profile("!" + JHipsterConstants.SPRING_PROFILE_CLOUD) | ||
@Import(value = MongoAutoConfiguration.class) | ||
@EnableMongoAuditing(auditorAwareRef = "springSecurityAuditorAware") | ||
public class DatabaseConfiguration { | ||
|
||
private final Logger log = LoggerFactory.getLogger(DatabaseConfiguration.class); | ||
|
||
@Bean | ||
public ValidatingMongoEventListener validatingMongoEventListener() { | ||
return new ValidatingMongoEventListener(validator()); | ||
} | ||
|
||
@Bean | ||
public LocalValidatorFactoryBean validator() { | ||
return new LocalValidatorFactoryBean(); | ||
} | ||
|
||
@Bean | ||
public MongoCustomConversions customConversions() { | ||
List<Converter<?, ?>> converters = new ArrayList<>(); | ||
converters.add(DateToZonedDateTimeConverter.INSTANCE); | ||
converters.add(ZonedDateTimeToDateConverter.INSTANCE); | ||
return new MongoCustomConversions(converters); | ||
} | ||
|
||
/* As per issue https://github.com/jhipster/generator-jhipster/issues/8665, Mongo Atlas has problems with Mongobee; so we | ||
* replace this file at deployment time with the following annotation commented out. | ||
*/ | ||
// @Bean | ||
public Mongobee mongobee(MongoClient mongoClient, MongoTemplate mongoTemplate, MongoProperties mongoProperties) { | ||
log.debug("Configuring Mongobee"); | ||
Mongobee mongobee = new Mongobee(mongoClient); | ||
mongobee.setDbName(mongoProperties.getMongoClientDatabase()); | ||
mongobee.setMongoTemplate(mongoTemplate); | ||
// package to scan for migrations | ||
mongobee.setChangeLogsScanPackage("com.openarchitex.accotech.config.dbmigrations"); | ||
mongobee.setEnabled(true); | ||
return mongobee; | ||
}} |