使用spring.data.mongodb.uri = mongodb:// otherhost / test进行Spring启动

时间:2017-01-04 23:48:37

标签: spring spring-boot spring-data-mongodb

我使用MongoDB开发了一个Spring启动应用程序。虽然MonghostDB在localhost中运行正常,但是当MongoDB与服务器不同时,我将application.properties中的设置更改为

spring.data.mongodb.uri=mongodb://192.168.7.31/gcp
spring.data.mongodb.username=xxx
spring.data.mongodb.password=xxxxxxx

应用程序失败,因为它仍然在localhost

中查找mongoDB
2017-01-04 11:47:46.161  INFO 15610 --- [           main] org.mongodb.driver.cluster               : Adding discovered server localhost:27017 to client view of cluster
2017-01-04 11:47:46.218  INFO 15610 --- [localhost:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.2.2.jar:na]
at  com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorR

任何人都可以帮忙告诉我如何设置参数?

0 个答案:

没有答案