内容简介:翻译自:https://stackoverflow.com/questions/35415308/exception-in-monitor-thread-while-connecting-to-server-localhost27017-while-acc
应用程序时,我有以下异常:
[localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017 while accessing MongoDB with Java
调用堆栈如下:
com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.0.4.jar:na] at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongodb-driver-core-3.0.4.jar:na] at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:127) ~[mongodb-driver-core-3.0.4.jar:na] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45] Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_45] at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_45] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) ~[na:1.8.0_45] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_45] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_45] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_45] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_45] at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_45] at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) ~[mongodb-driver-core-3.0.4.jar:na] at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.0.4.jar:na] ... 3 common frames omitted
这些名称都不属于我的申请.我在本地主机上也没有MONGODB服务器.我正在使用远程主机并稍后进行设置.关于Mongo的任何陈述之前都会发生异常.
UPDATE
这可能是一些Spring提供的bean访问Mongo.如何禁用它们?
我的配置包含以下依赖项:
dependencies { compile('javax.media:jai_core:1.1.3') //compile('jai_core:1.1.3') // compile('org.springframework.boot:spring-boot-starter-data-mongodb') compile('org.mongodb:mongodb-driver:3.0.4') compile('org.mongodb:bson:3.0.4') compile('org.geotools:gt-api:14.2') compile('org.geotools:gt-shapefile:14.2') compile('org.geotools:gt-geometry:14.2') compile('org.geotools:gt-referencing:14.2') compile('org.geotools:gt-geojson:14.2') compile('org.geotools:gt-mongodb:14.2') compile('org.springframework.boot:spring-boot-starter-web') providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') testCompile('org.springframework.boot:spring-boot-starter-test') }
即我已经删除了org.springframework.boot:spring-boot-starter-data-mongodb并且正在考虑将自己使用Mongo …
UPDATE2
我找到了相关的问题: How to disable spring-data-mongodb autoconfiguration in spring-boot
我是要在我的主要注释类中添加排除注释,
即代替
@SpringBootApplication
我应该
@SpringBootApplication @EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
翻译自:https://stackoverflow.com/questions/35415308/exception-in-monitor-thread-while-connecting-to-server-localhost27017-while-acc
以上所述就是小编给大家介绍的《使用Java访问MongoDB时连接到服务器localhost:27017时监视器线程中的异常》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Holy Lance 1.3 发布,Linux 图形化性能监视器
- java中线程安全,线程死锁,线程通信快速入门
- ObjC 多线程简析(一)-多线程简述和线程锁的基本应用
- Java多线程之线程中止
- Android 的线程和线程池
- iOS 多线程之线程安全
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Mission Python
Sean McManus / No Starch Press / 2018-9-18 / GBP 24.99
Launch into coding with Mission Python, a space-themed guide to building a complete computer game in Python. You'll learn programming fundamentals like loops, strings, and lists as you build Escape!, ......一起来看看 《Mission Python》 这本书的介绍吧!
RGB CMYK 转换工具
RGB CMYK 互转工具
HEX HSV 转换工具
HEX HSV 互换工具