Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Spring.data.mongodb.uri进行Spring引导=mongodb://otherhost/test_Spring_Spring Boot_Spring Data Mongodb - Fatal编程技术网

使用Spring.data.mongodb.uri进行Spring引导=mongodb://otherhost/test

使用Spring.data.mongodb.uri进行Spring引导=mongodb://otherhost/test,spring,spring-boot,spring-data-mongodb,Spring,Spring Boot,Spring Data Mongodb,我用MongoDB开发了一个Spring引导应用程序。虽然MongoDB在本地主机中运行,但工作正常,但是当MongoDB在服务器的不同位置时,我将application.properties中的设置更改为 spring.data.mongodb.uri=mongodb://192.168.7.31/gcp spring.data.mongodb.username=xxx spring.data.mongodb.password=xxxxxxx 应用程序失败,因为它仍在本地主机中查找mongo

我用MongoDB开发了一个Spring引导应用程序。虽然MongoDB在本地主机中运行,但工作正常,但是当MongoDB在服务器的不同位置时,我将application.properties中的设置更改为

spring.data.mongodb.uri=mongodb://192.168.7.31/gcp
spring.data.mongodb.username=xxx
spring.data.mongodb.password=xxxxxxx
应用程序失败,因为它仍在本地主机中查找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

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

您可以显示配置吗?确认您在创建MongoClient时没有硬编码url。请告诉我们您在哪里创建了MongoClient bean的代码(如果您已经创建了),您使用的是哪个版本的MongoDB?还请检查文档中有关使用
spring.data.mongodb.uri
的提示:能否显示配置?确认在创建MongoClient时没有对url进行硬编码。请告诉我们您在哪里创建了MongoClient bean的代码(如果您已经创建了),您使用的是哪个版本的MongoDB?还请检查文档中有关使用
spring.data.mongodb.uri的提示: