@ConditionalOnMissingBean lets Spring Boot autoconfiguration provide a bean only when an explicitly configured bean of the required type or name is absent. section 15.2.2
MongoTemplate autoconfiguration
When no MongoTemplate bean exists, the MongoTemplate autoconfiguration passes its condition and creates one. If a MongoTemplate has already been configured, this condition prevents that automatic replacement. section 15.2.2
{
"contexts": {
"application-1": {
"positiveMatches": {
...
"MongoDataAutoConfiguration#mongoTemplate": [
{
"condition": "OnBeanCondition",
"message": "@ConditionalOnMissingBean (types:
org.springframework.data.mongodb.core.MongoTemplate;
SearchStrategy: all) did not find any beans"
}
],
...
},
"negativeMatches": {
...
"DispatcherServletAutoConfiguration": {
"notMatched": [
{
"condition": "OnClassCondition",
"message": "@ConditionalOnClass did not find required
class 'org.springframework.web.servlet.
DispatcherServlet'"
}
],
"matched": []
},
...
},
"unconditionalClasses": [
...
"org.springframework.boot.autoconfigure.context.
ConfigurationPropertiesAutoConfiguration",
...
]
}
}
}
Inspect /actuator/conditions to see positive matches, negative matches, and unconditional classes, including the condition message confirming that no MongoTemplate bean was found. section 15.2.2
