diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java index e0b3edf755..b71bf74abe 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java @@ -16,16 +16,17 @@ package org.springframework.boot.autoconfigure.mongo; +import java.net.UnknownHostException; + +import org.springframework.boot.context.properties.ConfigurationProperties; + import com.mongodb.DBPort; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; -import org.springframework.boot.context.properties.ConfigurationProperties; - -import java.net.UnknownHostException; /** * Configuration properties for Mongo. - * + * * @author Dave Syer * @author Phillip Webb * @author Josh Long @@ -33,69 +34,68 @@ import java.net.UnknownHostException; @ConfigurationProperties(prefix = "spring.data.mongodb") public class MongoProperties { - private String host; - - private int port = DBPort.PORT; + private String host; - private String uri = "mongodb://localhost/test"; + private int port = DBPort.PORT; - private String database; + private String uri = "mongodb://localhost/test"; - private String gridFsDatabase; + private String database; + private String gridFsDatabase; - public String getHost() { - return this.host; - } + public String getHost() { + return this.host; + } - public void setHost(String host) { - this.host = host; - } + public void setHost(String host) { + this.host = host; + } - public String getDatabase() { - return this.database; - } + public String getDatabase() { + return this.database; + } - public void setDatabase(String database) { - this.database = database; - } + public void setDatabase(String database) { + this.database = database; + } - public String getUri() { - return this.uri; - } + public String getUri() { + return this.uri; + } - public void setUri(String uri) { - this.uri = uri; - } + public void setUri(String uri) { + this.uri = uri; + } - public int getPort() { - return this.port; - } + public int getPort() { + return this.port; + } - public void setPort(int port) { - this.port = port; - } + public void setPort(int port) { + this.port = port; + } - public String getGridFsDatabase() { - return gridFsDatabase; - } + public String getGridFsDatabase() { + return this.gridFsDatabase; + } - public void setGridFsDatabase(String gridFsDatabase) { - this.gridFsDatabase = gridFsDatabase; - } + public void setGridFsDatabase(String gridFsDatabase) { + this.gridFsDatabase = gridFsDatabase; + } - public String getMongoClientDatabase() { - if (this.database != null) { - return this.database; - } - return new MongoClientURI(this.uri).getDatabase(); - } + public String getMongoClientDatabase() { + if (this.database != null) { + return this.database; + } + return new MongoClientURI(this.uri).getDatabase(); + } - public MongoClient createMongoClient() throws UnknownHostException { - if (this.host != null) { - return new MongoClient(this.host, this.port); - } - return new MongoClient(new MongoClientURI(this.uri)); - } + public MongoClient createMongoClient() throws UnknownHostException { + if (this.host != null) { + return new MongoClient(this.host, this.port); + } + return new MongoClient(new MongoClientURI(this.uri)); + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoTemplateAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoTemplateAutoConfiguration.java index d5e340dce5..854053b1a5 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoTemplateAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoTemplateAutoConfiguration.java @@ -33,11 +33,10 @@ import org.springframework.util.StringUtils; import com.mongodb.Mongo; /** - * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's - * {@link MongoTemplate}. + * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's mongo support. *

- * Registers a {@link org.springframework.data.mongodb.core.MongoTemplate} bean if no - * other bean of the same type is configured. + * Registers a {@link MongoTemplate} and {@link GridFsTemplate} beans if no other beans of + * the same type are configured. *

* Honors the {@literal spring.data.mongodb.database} property if set, otherwise connects * to the {@literal test} database. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/GridFsTemplateAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoTemplateAutoConfigurationTests.java similarity index 87% rename from spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/GridFsTemplateAutoConfigurationTests.java rename to spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoTemplateAutoConfigurationTests.java index da9e957116..5c015db2f7 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/GridFsTemplateAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoTemplateAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -25,12 +25,11 @@ import org.springframework.data.mongodb.gridfs.GridFsTemplate; import static org.junit.Assert.assertEquals; /** - * Tests for - * {@link org.springframework.boot.autoconfigure.mongo.MongoTemplateAutoConfiguration}. - * + * Tests for {@link MongoTemplateAutoConfiguration}. + * * @author Josh Long */ -public class GridFsTemplateAutoConfigurationTests { +public class MongoTemplateAutoConfigurationTests { private AnnotationConfigApplicationContext context;