From 2003c5e1aebc29baf7142b9eb58b8bc254932449 Mon Sep 17 00:00:00 2001 From: Julien May Date: Wed, 22 Jun 2016 11:54:47 +0200 Subject: [PATCH 1/2] 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 --- .../mongo/embedded/EmbeddedMongoAutoConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index 94ec8017c4..a96fce403c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -63,6 +63,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; +import org.springframework.data.mongodb.core.MongoClientFactoryBean; import org.springframework.util.Assert; /** @@ -199,7 +200,7 @@ public class EmbeddedMongoAutoConfiguration { * {@code embeddedMongoServer} bean. */ @Configuration - @ConditionalOnClass(MongoClient.class) + @ConditionalOnClass({MongoClient.class, MongoClientFactoryBean.class}) protected static class EmbeddedMongoDependencyConfiguration extends MongoClientDependsOnBeanFactoryPostProcessor { From 7a5fabf59d838c3e70cc24b38ddc41db773504ce Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 27 Jun 2016 14:55:47 +0200 Subject: [PATCH 2/2] Polish "Add condition on MongoClientFactoryBean" Closes gh-6203 --- .../mongo/embedded/EmbeddedMongoAutoConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index a96fce403c..fac8faf114 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -200,7 +200,7 @@ public class EmbeddedMongoAutoConfiguration { * {@code embeddedMongoServer} bean. */ @Configuration - @ConditionalOnClass({MongoClient.class, MongoClientFactoryBean.class}) + @ConditionalOnClass({ MongoClient.class, MongoClientFactoryBean.class }) protected static class EmbeddedMongoDependencyConfiguration extends MongoClientDependsOnBeanFactoryPostProcessor {