In MyMongoConfig extends AbstractReactiveMongoConfiguration
I created a bean when using version 3.2 of spring-data-mongodb:
@Override
public MongoMappingContext mongoMappingContext(MongoCustomConversions customConversions) throws ClassNotFoundException {
return super.mongoMappingContext(customConversions);
}
which needs to be changed after upgrading to version 4.0 to:
@Override
public MongoMappingContext mongoMappingContext(MongoCustomConversions customConversions, MongoManagedTypes types) {
return super.mongoMappingContext(customConversions(), types);
}
but this gives an error because MongoManagedTypes
is not set. What are MongoManagedTypes
and how do we set them?
When the beans are initialized the size of types
is 0, and I get an error message:
Factory method 'mongoMappingContext' threw exception with message: Error creating bean with name 'customConversions' defined in class path resource
factory bean 'MyMongoConfig'; factory method 'customConversions()'. Check that a method with the specified name exists and that it is non-static.
However, customConversion() works prior to upgrading to version 4.0
Edit: The change from not needing MongoManagedTypes to needing it was done in this commit: https://github.com/spring-projects/spring-data-mongodb/commit/cfd55be95bf7bf70bc1fdf243209591c0b0c4d5b in java/org/springframework/data/mongodb/config/MongoConfigurationSupport.java
Related issue: https://github.com/spring-projects/spring-data-mongodb/issues/4365