|
|
@ -21,6 +21,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.domain.EntityScanner;
|
|
|
|
import org.springframework.boot.autoconfigure.domain.EntityScanner;
|
|
|
|
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
|
|
|
|
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
|
|
|
|
|
|
|
|
import org.springframework.boot.context.properties.PropertyMapper;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
@ -34,6 +35,7 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
|
|
|
* Base configuration class for Spring Data's mongo support.
|
|
|
|
* Base configuration class for Spring Data's mongo support.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Madhura Bhave
|
|
|
|
* @author Madhura Bhave
|
|
|
|
|
|
|
|
* @author Artsiom Yudovin
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
class MongoDataConfiguration {
|
|
|
|
class MongoDataConfiguration {
|
|
|
@ -43,7 +45,9 @@ class MongoDataConfiguration {
|
|
|
|
public MongoMappingContext mongoMappingContext(ApplicationContext applicationContext,
|
|
|
|
public MongoMappingContext mongoMappingContext(ApplicationContext applicationContext,
|
|
|
|
MongoProperties properties, MongoCustomConversions conversions)
|
|
|
|
MongoProperties properties, MongoCustomConversions conversions)
|
|
|
|
throws ClassNotFoundException {
|
|
|
|
throws ClassNotFoundException {
|
|
|
|
|
|
|
|
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
|
|
MongoMappingContext context = new MongoMappingContext();
|
|
|
|
MongoMappingContext context = new MongoMappingContext();
|
|
|
|
|
|
|
|
mapper.from(properties.isAutoIndexCreation()).to(context::setAutoIndexCreation);
|
|
|
|
context.setInitialEntitySet(new EntityScanner(applicationContext)
|
|
|
|
context.setInitialEntitySet(new EntityScanner(applicationContext)
|
|
|
|
.scan(Document.class, Persistent.class));
|
|
|
|
.scan(Document.class, Persistent.class));
|
|
|
|
Class<?> strategyClass = properties.getFieldNamingStrategy();
|
|
|
|
Class<?> strategyClass = properties.getFieldNamingStrategy();
|
|
|
|