【发布时间】:2019-07-27 13:52:18
【问题描述】:
我正在使用 MongoDB 的默认 docker 映像,并尝试在 windows 框中使用简单的 spring Boot 应用程序进行连接。
mongoDB 图像被正确盯着
我的课程路径中有spring-boot-starter-data-mongodb。我正在使用所有 Spring Boot 默认值,并且仅在 application.properties 中使用以下属性。
spring.data.mongodb.host=192.168.99.100
在应用程序启动时得到Connection denied: connect错误
日志
019-03-06 06:15:06.096 INFO 4664 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[192.168.99.100:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-03-06 06:15:06.096 INFO 4664 --- [ main] org.mongodb.driver.cluster : Adding discovered server 192.168.99.100:27017 to client view of cluster
2019-03-06 06:15:06.356 WARN 4664 --- [ main] o.s.d.m.c.m.BasicMongoPersistentProperty : Customizing field name for id property not allowed! Custom name will not be considered!
2019-03-06 06:15:06.928 INFO 4664 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-03-06 06:15:07.164 INFO 4664 --- [68.99.100:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server 192.168.99.100:27017
我在这里缺少什么?
【问题讨论】:
-
您可以使用命令行或指南针进行连接吗?
-
感谢您的检查,我是 Mongo 和 docker 的新手。我该如何检查?
-
是的,我可以使用命令行连接
-
也许在 mongod.conf 中你需要更改 bind_ip = 0.0.0.0。默认是本地主机
标签: spring mongodb spring-boot docker