|
|
@@ -5,10 +5,10 @@ import com.mongodb.MongoClientURI;
|
|
|
import com.uas.kanban.util.ContextUtils;
|
|
|
import org.mongodb.morphia.Datastore;
|
|
|
import org.mongodb.morphia.Morphia;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
/**
|
|
|
* mongo配置
|
|
|
@@ -16,24 +16,60 @@ import org.springframework.context.annotation.Primary;
|
|
|
* @author sunyj
|
|
|
* @since 2017年8月28日 下午3:16:39
|
|
|
*/
|
|
|
-@Configuration
|
|
|
+@Component
|
|
|
+@ConfigurationProperties(prefix = "mongo")
|
|
|
public class MongoConfiguration {
|
|
|
|
|
|
- @Value("${mongo.host}")
|
|
|
private String host;
|
|
|
|
|
|
- @Value("${mongo.port}")
|
|
|
private Integer port;
|
|
|
|
|
|
- @Value("${mongo.username}")
|
|
|
private String username;
|
|
|
|
|
|
- @Value("${mongo.password}")
|
|
|
private String password;
|
|
|
|
|
|
- @Value("${mongo.dbName}")
|
|
|
private String dbName;
|
|
|
|
|
|
+ public String getHost() {
|
|
|
+ return host;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setHost(String host) {
|
|
|
+ this.host = host;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer getPort() {
|
|
|
+ return port;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPort(Integer port) {
|
|
|
+ this.port = port;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getUsername() {
|
|
|
+ return username;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setUsername(String username) {
|
|
|
+ this.username = username;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getPassword() {
|
|
|
+ return password;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPassword(String password) {
|
|
|
+ this.password = password;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getDbName() {
|
|
|
+ return dbName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setDbName(String dbName) {
|
|
|
+ this.dbName = dbName;
|
|
|
+ }
|
|
|
+
|
|
|
@Bean
|
|
|
@Primary
|
|
|
public MongoClient mongoClient() {
|