mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Add @ConditionalOnMissingBean(MongoDbFactory)
Update MongoAutoConfiguration to be conditional on a missing MongoDbFactory bean. The assumption is that if the user has declared a MongoDbFactory they will either use it directly, or they will also register a Mongo bean. If the MongoDbFactory class cannot be found the existing Mongo auto-configuration still applies. This ensures that users that do not have Spring Data can still access a Mongo bean. Fixes gh-1341
This commit is contained in:
parent
e0c3dd79f9
commit
45c8eca4f2
@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoClientOptions;
|
||||
@ -41,6 +42,7 @@ import com.mongodb.MongoClientOptions;
|
||||
@Configuration
|
||||
@ConditionalOnClass(Mongo.class)
|
||||
@EnableConfigurationProperties(MongoProperties.class)
|
||||
@ConditionalOnMissingBean(MongoDbFactory.class)
|
||||
public class MongoAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
|
Loading…
Reference in New Issue
Block a user