你好,
spring boot 自动配置两个 MongoDB 客户端,一个通过 MongoAutoConfiguration,一个通过 MongoReactiveAutoConfiguration。如果我尝试排除 MongoAutoConfiguration 我收到以下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method mongoDbFactory in org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration required a bean of type 'com.mongodb.MongoClient' that could not be found.
- Bean method 'mongo' not loaded because auto-configuration 'MongoAutoConfiguration' was excluded
然后,如果我也尝试排除 MongoDataAutoConfiguration,则会收到以下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 1 of method reactiveMongoTemplate in org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration required a bean of type 'org.springframework.data.mongodb.core.convert.MongoConverter' that could not be found.
- Bean method 'mappingMongoConverter' not loaded because auto-configuration 'MongoDataAutoConfiguration' was excluded
看起来不可能排除非反应部分。下面您可以找到一个简单的示例,其中“使用设置创建的集群....等”被记录两次: https://github.com/cmario/spring-boot-embedded-mongodb
问候马里奥