Skip to content

Commit 006d7b6

Browse files
author
Dave Syer
committed
Move MongoTemplateAutoConfiguration to mongo package
1 parent 01775ba commit 006d7b6

File tree

5 files changed

+53
-5
lines changed

5 files changed

+53
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ public Mongo mongo() throws UnknownHostException {
6060
this.mongo = this.properties.createMongoClient();
6161
return this.mongo;
6262
}
63+
6364
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.data;
17+
package org.springframework.boot.autoconfigure.mongo;
1818

1919
import java.net.UnknownHostException;
2020

2121
import org.springframework.beans.factory.annotation.Autowired;
2222
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2323
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
25-
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
2625
import org.springframework.context.annotation.Bean;
2726
import org.springframework.context.annotation.Configuration;
2827
import org.springframework.data.mongodb.core.MongoTemplate;
29-
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
3028

3129
import com.mongodb.Mongo;
3230

@@ -43,7 +41,6 @@
4341
* @author Dave Syer
4442
* @author Oliver Gierke
4543
* @author Josh Long
46-
* @see EnableMongoRepositories
4744
*/
4845
@Configuration
4946
@ConditionalOnClass({ Mongo.class, MongoTemplate.class })

spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration,\
1111
org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
1212
org.springframework.boot.autoconfigure.data.JpaRepositoriesAutoConfiguration,\
1313
org.springframework.boot.autoconfigure.data.MongoRepositoriesAutoConfiguration,\
14-
org.springframework.boot.autoconfigure.data.MongoTemplateAutoConfiguration,\
1514
org.springframework.boot.autoconfigure.redis.RedisAutoConfiguration,\
1615
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
1716
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
1817
org.springframework.boot.autoconfigure.jms.JmsTemplateAutoConfiguration,\
1918
org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,\
2019
org.springframework.boot.autoconfigure.mobile.DeviceResolverAutoConfiguration,\
2120
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\
21+
org.springframework.boot.autoconfigure.mongo.MongoTemplateAutoConfiguration,\
2222
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
2323
org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration,\
2424
org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,\

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/MongoRepositoriesAutoConfigurationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.boot.autoconfigure.data.mongo.City;
2424
import org.springframework.boot.autoconfigure.data.mongo.CityRepository;
2525
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
26+
import org.springframework.boot.autoconfigure.mongo.MongoTemplateAutoConfiguration;
2627
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
2728
import org.springframework.context.annotation.Configuration;
2829
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2012-2013 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.mongo;
18+
19+
import org.junit.After;
20+
import org.junit.Test;
21+
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
22+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
23+
import org.springframework.data.mongodb.core.MongoTemplate;
24+
25+
import static org.junit.Assert.assertEquals;
26+
27+
/**
28+
* @author Dave Syer
29+
*/
30+
public class MongoAutoConfigurationTests {
31+
32+
private AnnotationConfigApplicationContext context;
33+
34+
@After
35+
public void close() {
36+
if (this.context != null) {
37+
this.context.close();
38+
}
39+
}
40+
41+
@Test
42+
public void templateExists() {
43+
this.context = new AnnotationConfigApplicationContext(
44+
PropertyPlaceholderAutoConfiguration.class, MongoAutoConfiguration.class,
45+
MongoTemplateAutoConfiguration.class);
46+
assertEquals(1, this.context.getBeanNamesForType(MongoTemplate.class).length);
47+
}
48+
49+
}

0 commit comments

Comments
 (0)