Reputation: 825
I have been working in a application with Spring webflux and reactive mongo DB. in there i used mongo DB atlas as the database and it worked fine.
Recently i had to introduce mongo custom conversion to handle the Zoned Date Time objects.
@Configuration
public class MongoReactiveConfiguration extends AbstractReactiveMongoConfiguration{
@Override
public MongoCustomConversions customConversions() {
ZonedDateTimeReadConverter zonedDateTimeReadConverter = new ZonedDateTimeReadConverter();
ZonedDateTimeWriteConverter zonedDateTimeWriteConverter = new ZonedDateTimeWriteConverter();
List<Converter<?, ?>> converterList = new ArrayList<>();
converterList.add(zonedDateTimeReadConverter);
converterList.add(zonedDateTimeWriteConverter);
return new MongoCustomConversions(converterList);
}
@Override
protected String getDatabaseName() {
// TODO Auto-generated method stub
return "stlDB";
}
}
HoOwever now i no longer can connect to mongo db atlas, it ignores the proeprty spring.data.mongodb.uri and tries to connect local server with default configuration.
i tried
@EnableAutoConfiguration(exclude={MongoReactiveAutoConfiguration.class})
but then it ignored the above conversions as well. Is there any other configurations to override in AbstractReactiveMongoConfiguration
to ignore the default server IP and port?
Upvotes: 0
Views: 350
Reputation: 51
I had the same issue and could not find a solution other than configuring converters differently, without extending AbstractReactiveMongoConfiguration:
@Configuration
public class MongoAlternativeConfiguration {
@Bean
public MongoCustomConversions mongoCustomConversions() {
return new MongoCustomConversions(
Arrays.asList(
new ZonedDateTimeReadConverter(),
new ZonedDateTimeWriteConverter()));
}
}
Upvotes: 2