Skip to content

Commit 2003c5e

Browse files
julien-maysnicoll
authored andcommitted
Add condition on MongoClientFactoryBean
This commit makes sure that the condition that links a `MongoClient` to the embedded mongo server kicks in only if `MongoClientFactoryBean` is also on the classpath. Previously, only a condition on the mongo driver existed, leading to `ClassNotFoundException` if Spring Data MongoDB wasn't available. See gh-6203
1 parent 17f8a24 commit 2003c5e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.springframework.core.env.MapPropertySource;
6464
import org.springframework.core.env.MutablePropertySources;
6565
import org.springframework.core.env.PropertySource;
66+
import org.springframework.data.mongodb.core.MongoClientFactoryBean;
6667
import org.springframework.util.Assert;
6768

6869
/**
@@ -199,7 +200,7 @@ private Map<String, Object> getMongoPorts(MutablePropertySources sources) {
199200
* {@code embeddedMongoServer} bean.
200201
*/
201202
@Configuration
202-
@ConditionalOnClass(MongoClient.class)
203+
@ConditionalOnClass({MongoClient.class, MongoClientFactoryBean.class})
203204
protected static class EmbeddedMongoDependencyConfiguration
204205
extends MongoClientDependsOnBeanFactoryPostProcessor {
205206

0 commit comments

Comments
 (0)