diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.java index 20b53c8b11..6f2dc39569 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.java @@ -20,7 +20,6 @@ import java.net.UnknownHostException; import java.util.Collections; import com.mongodb.DB; -import com.mongodb.Mongo; import com.mongodb.MongoClient; import org.springframework.beans.BeanUtils; @@ -72,7 +71,7 @@ import org.springframework.util.StringUtils; * @since 1.1.0 */ @Configuration -@ConditionalOnClass({ Mongo.class, MongoTemplate.class }) +@ConditionalOnClass({ MongoClient.class, MongoTemplate.class }) @EnableConfigurationProperties(MongoProperties.class) @AutoConfigureAfter(MongoAutoConfiguration.class) public class MongoDataAutoConfiguration { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfiguration.java index 1afa03ff98..035b18b230 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2017 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. @@ -16,7 +16,7 @@ package org.springframework.boot.autoconfigure.data.mongo; -import com.mongodb.Mongo; +import com.mongodb.MongoClient; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -52,7 +52,7 @@ import org.springframework.data.mongodb.repository.support.MongoRepositoryFactor * @see EnableMongoRepositories */ @Configuration -@ConditionalOnClass({ Mongo.class, MongoRepository.class }) +@ConditionalOnClass({ MongoClient.class, MongoRepository.class }) @ConditionalOnMissingBean({ MongoRepositoryFactoryBean.class, MongoRepositoryConfigurationExtension.class }) @ConditionalOnProperty(prefix = "spring.data.mongodb.repositories", name = "enabled", havingValue = "true", matchIfMissing = true) 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 cd7a308f68..ec63ff7a0a 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 @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import com.mongodb.Mongo; import com.mongodb.MongoClient; import de.flapdoodle.embed.mongo.Command; import de.flapdoodle.embed.mongo.MongodExecutable; @@ -77,7 +76,7 @@ import org.springframework.util.Assert; @Configuration @EnableConfigurationProperties({ MongoProperties.class, EmbeddedMongoProperties.class }) @AutoConfigureBefore(MongoAutoConfiguration.class) -@ConditionalOnClass({ Mongo.class, MongodStarter.class }) +@ConditionalOnClass({ MongoClient.class, MongodStarter.class }) public class EmbeddedMongoAutoConfiguration { private static final byte[] IP4_LOOPBACK_ADDRESS = { 127, 0, 0, 1 }; diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java index 07ee35fea2..3dbd373dc9 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java @@ -20,7 +20,7 @@ import java.time.LocalDateTime; import java.util.Arrays; import java.util.Set; -import com.mongodb.Mongo; +import com.mongodb.MongoClient; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -101,8 +101,8 @@ public class MongoDataAutoConfigurationTests { MongoAutoConfiguration.class, MongoDataAutoConfiguration.class); this.context.refresh(); MongoTemplate template = this.context.getBean(MongoTemplate.class); - assertThat(template.getConverter().getConversionService().canConvert(Mongo.class, - Boolean.class)).isTrue(); + assertThat(template.getConverter().getConversionService() + .canConvert(MongoClient.class, Boolean.class)).isTrue(); } @Test @@ -210,10 +210,10 @@ public class MongoDataAutoConfigurationTests { } - private static class MyConverter implements Converter { + private static class MyConverter implements Converter { @Override - public Boolean convert(Mongo source) { + public Boolean convert(MongoClient source) { return null; } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java index fd169b7d79..0463acac82 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.data.mongo; import java.util.Set; -import com.mongodb.Mongo; import com.mongodb.MongoClient; import org.junit.After; import org.junit.Test; @@ -59,8 +58,7 @@ public class MongoRepositoriesAutoConfigurationTests { prepareApplicationContext(TestConfiguration.class); assertThat(this.context.getBean(CityRepository.class)).isNotNull(); - Mongo mongo = this.context.getBean(Mongo.class); - assertThat(mongo).isInstanceOf(MongoClient.class); + assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1); MongoMappingContext mappingContext = this.context .getBean(MongoMappingContext.class); @SuppressWarnings("unchecked") @@ -72,9 +70,7 @@ public class MongoRepositoriesAutoConfigurationTests { @Test public void testNoRepositoryConfiguration() throws Exception { prepareApplicationContext(EmptyConfiguration.class); - - Mongo mongo = this.context.getBean(Mongo.class); - assertThat(mongo).isInstanceOf(MongoClient.class); + assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1); } @Test diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java index 888ff87d98..3c7a9a5a94 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.mongo; import javax.net.SocketFactory; -import com.mongodb.Mongo; import com.mongodb.MongoClient; import com.mongodb.MongoClientOptions; import org.junit.After; @@ -54,7 +53,7 @@ public class MongoAutoConfigurationTests { public void clientExists() { this.context = new AnnotationConfigApplicationContext( PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class); - assertThat(this.context.getBeanNamesForType(Mongo.class).length).isEqualTo(1); + assertThat(this.context.getBeanNamesForType(MongoClient.class)).hasSize(1); } @Test