Skip to content

Fix documentation on custom converters [DATAMONGO-2526] #3381

Closed
@spring-projects-issues

Description

@spring-projects-issues

Piotr Kubowicz opened DATAMONGO-2526 and commented

According to https://docs.spring.io/spring-data/mongodb/docs/2.2.3.RELEASE/reference/html/#mapping-configuration the way to register custom converters is to override AbstractMongoConfiguration.

 

Problem 1: AbstractMongoConfiguration is deprecated in favour of AbstractMongoClientConfiguration

Problem 2: neither AbstractMongoConfiguration nor AbstractMongoClientConfiguration is a sensible way to register custom coverters as they require implementing abstract methods and providing database name and configuring Mongo client. I don't want to specify any of that! This will break Spring Boot autoconfiguration. My Mongo client connects to different hosts on different environments. The host should be selected in configuration, not in code. I shouldn't be required to touch unrelated things if I want to perform a simple task: register custom converters.

Figuring out how to register custom converters is not easy because of complex dependencies between Spring Boot autoconfiguration and Spring Data Mongo. The best way I found is to register a bean of type MongoCustomConversions.

This method should be probably suggested in the documentation instead of overriding abstract configurations


No further details from DATAMONGO-2526

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions