|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2012-2022 the original author or authors. |
|
|
|
|
* Copyright 2012-2024 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.data.mongo;
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.data.mongo;
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.ObjectProvider; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
|
|
|
import org.springframework.boot.autoconfigure.domain.EntityScanner; |
|
|
|
|
import org.springframework.boot.autoconfigure.mongo.MongoProperties; |
|
|
|
|
@ -27,8 +28,14 @@ import org.springframework.context.ApplicationContext;
@@ -27,8 +28,14 @@ import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import org.springframework.data.mapping.model.FieldNamingStrategy; |
|
|
|
|
import org.springframework.data.mongodb.MongoDatabaseFactory; |
|
|
|
|
import org.springframework.data.mongodb.MongoManagedTypes; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.DbRefResolver; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.MappingMongoConverter; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.MongoConverter; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.MongoCustomConversions; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver; |
|
|
|
|
import org.springframework.data.mongodb.core.mapping.Document; |
|
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoMappingContext; |
|
|
|
|
|
|
|
|
|
@ -70,4 +77,16 @@ class MongoDataConfiguration {
@@ -70,4 +77,16 @@ class MongoDataConfiguration {
|
|
|
|
|
return new MongoCustomConversions(Collections.emptyList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
@ConditionalOnMissingBean(MongoConverter.class) |
|
|
|
|
MappingMongoConverter mappingMongoConverter(ObjectProvider<MongoDatabaseFactory> factory, |
|
|
|
|
MongoMappingContext context, MongoCustomConversions conversions) { |
|
|
|
|
MongoDatabaseFactory mongoDatabaseFactory = factory.getIfAvailable(); |
|
|
|
|
DbRefResolver dbRefResolver = (mongoDatabaseFactory != null) ? new DefaultDbRefResolver(mongoDatabaseFactory) |
|
|
|
|
: NoOpDbRefResolver.INSTANCE; |
|
|
|
|
MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, context); |
|
|
|
|
mappingConverter.setCustomConversions(conversions); |
|
|
|
|
return mappingConverter; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|