org.zodiac.autoconfigure.mongo.MongoAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.mongo;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
import org.zodiac.commons.util.Colls;
import org.zodiac.mongo.converter.DBObjectToJsonNodeConverter;
import org.zodiac.mongo.converter.JsonNodeToDocumentConverter;
import java.util.List;
@SpringBootConfiguration
@ConditionalOnClass(name = {"com.mongodb.MongoClient"})
@AutoConfigureAfter(value = {org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class})
public class MongoAutoConfiguration {
@Bean
protected MongoCustomConversions customConversions() {
List> converters = Colls.list(DBObjectToJsonNodeConverter.INSTANCE, JsonNodeToDocumentConverter.INSTANCE);
return new MongoCustomConversions(converters);
}
}