This was originally mentioned a few months ago here. I've completely missed the reply from Andy so creating the issue right now. Sorry for the delay.
If you have registered your own MongoClientSettings
bean and you also use Embedded MongoDB for testing repositories then after you upgrade to Spring Boot 2.4.0, MongoClient
won't be able to connect to a random port Embedded MongoDB really listens on. It would always try to connect to the default mongo port 27017. The reason is that in versions <= 2.3.6, any existing MongoClientSettings
bean gets customized automatically without any additional configuration but in 2.4.0, you have to register MongoPropertiesClientSettingsBuilderCustomizer
manually in order to get the embedded port resolved. Like:
@Bean
public MongoPropertiesClientSettingsBuilderCustomizer mongoClientSettingsCustomizer(MongoProperties props, Environment env) {
return new MongoPropertiesClientSettingsBuilderCustomizer(props, env);
}
That information is missing in the release notes for version 2.4.0. Without the customizer registered extra, all existing mongo repository tests are going to fail.
Comment From: snicoll
I've added a section in the release notes for 2.4