Class AbstractMongoClientConfiguration
java.lang.Object
org.springframework.data.mongodb.config.MongoConfigurationSupport
org.springframework.data.mongodb.config.AbstractMongoClientConfiguration
@Configuration(proxyBeanMethods=false)
public abstract class AbstractMongoClientConfiguration
extends MongoConfigurationSupport
Base class for Spring Data MongoDB configuration using JavaConfig with
MongoClient
.- Since:
- 2.1
- Author:
- Christoph Strobl
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected com.mongodb.client.MongoClient
createMongoClient
(com.mongodb.MongoClientSettings settings) Create the Reactive StreamsMongoClient
instance with givenMongoClientSettings
.mappingMongoConverter
(MongoDatabaseFactory databaseFactory, MongoCustomConversions customConversions, MongoMappingContext mappingContext) Creates aMappingMongoConverter
using the configuredmongoDbFactory()
andMongoConfigurationSupport.mongoMappingContext(MongoCustomConversions)
.com.mongodb.client.MongoClient
Return theMongoClient
instance to connect to.Creates aSimpleMongoClientDatabaseFactory
to be used by theMongoTemplate
.mongoTemplate
(MongoDatabaseFactory databaseFactory, MappingMongoConverter converter) Creates aMongoTemplate
.Methods inherited from class org.springframework.data.mongodb.config.MongoConfigurationSupport
abbreviateFieldNames, autoIndexCreation, configureClientSettings, configureConverters, customConversions, fieldNamingStrategy, getDatabaseName, getInitialEntitySet, getMappingBasePackages, mongoClientSettings, mongoMappingContext, scanForEntities
-
Constructor Details
-
AbstractMongoClientConfiguration
public AbstractMongoClientConfiguration()
-
-
Method Details
-
mongoClient
public com.mongodb.client.MongoClient mongoClient()Return theMongoClient
instance to connect to. Annotate withBean
in case you want to expose aMongoClient
instance to theApplicationContext
.
OverrideMongoConfigurationSupport.mongoClientSettings()
to configure connection details.- Returns:
- never null.
- See Also:
-
mongoTemplate
@Bean public MongoTemplate mongoTemplate(MongoDatabaseFactory databaseFactory, MappingMongoConverter converter) Creates aMongoTemplate
. -
mongoDbFactory
Creates aSimpleMongoClientDatabaseFactory
to be used by theMongoTemplate
. Will use theMongoClient
instance configured inmongoClient()
. -
mappingMongoConverter
@Bean public MappingMongoConverter mappingMongoConverter(MongoDatabaseFactory databaseFactory, MongoCustomConversions customConversions, MongoMappingContext mappingContext) Creates aMappingMongoConverter
using the configuredmongoDbFactory()
andMongoConfigurationSupport.mongoMappingContext(MongoCustomConversions)
. Will getMongoConfigurationSupport.customConversions()
applied. -
createMongoClient
protected com.mongodb.client.MongoClient createMongoClient(com.mongodb.MongoClientSettings settings) Create the Reactive StreamsMongoClient
instance with givenMongoClientSettings
.- Returns:
- never null.
- Since:
- 3.0
-