<small id='Tdv8q'></small><noframes id='Tdv8q'>

          <bdo id='Tdv8q'></bdo><ul id='Tdv8q'></ul>
      1. <tfoot id='Tdv8q'></tfoot>
        <i id='Tdv8q'><tr id='Tdv8q'><dt id='Tdv8q'><q id='Tdv8q'><span id='Tdv8q'><b id='Tdv8q'><form id='Tdv8q'><ins id='Tdv8q'></ins><ul id='Tdv8q'></ul><sub id='Tdv8q'></sub></form><legend id='Tdv8q'></legend><bdo id='Tdv8q'><pre id='Tdv8q'><center id='Tdv8q'></center></pre></bdo></b><th id='Tdv8q'></th></span></q></dt></tr></i><div id='Tdv8q'><tfoot id='Tdv8q'></tfoot><dl id='Tdv8q'><fieldset id='Tdv8q'></fieldset></dl></div>

      2. <legend id='Tdv8q'><style id='Tdv8q'><dir id='Tdv8q'><q id='Tdv8q'></q></dir></style></legend>
      3. 使用 Java 访问 MongoDB 时连接到服务器 localhost:27017 时监控线程出现异常

        时间:2024-08-24

        <small id='fwSvh'></small><noframes id='fwSvh'>

          • <bdo id='fwSvh'></bdo><ul id='fwSvh'></ul>

            1. <tfoot id='fwSvh'></tfoot>
              <legend id='fwSvh'><style id='fwSvh'><dir id='fwSvh'><q id='fwSvh'></q></dir></style></legend>

                    <tbody id='fwSvh'></tbody>

                  <i id='fwSvh'><tr id='fwSvh'><dt id='fwSvh'><q id='fwSvh'><span id='fwSvh'><b id='fwSvh'><form id='fwSvh'><ins id='fwSvh'></ins><ul id='fwSvh'></ul><sub id='fwSvh'></sub></form><legend id='fwSvh'></legend><bdo id='fwSvh'><pre id='fwSvh'><center id='fwSvh'></center></pre></bdo></b><th id='fwSvh'></th></span></q></dt></tr></i><div id='fwSvh'><tfoot id='fwSvh'></tfoot><dl id='fwSvh'><fieldset id='fwSvh'></fieldset></dl></div>
                  本文介绍了使用 Java 访问 MongoDB 时连接到服务器 localhost:27017 时监控线程出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在为 MongoDB 运行 Java 应用程序时出现以下异常:

                  I have the following exception when running Java app for MongoDB:

                  [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 的任何陈述之前发生异常.

                  Neither of these names belong to my application. Also I have NO MONGODB server on local host. I am using remote host and setting it later. An exception occurs BEFORE any of my statements concerning Mongo.

                  更新

                  这可能是一些 Spring 提供的 bean 访问 Mongo.如何禁用它们?

                  This is probably some Spring provided beans accessing Mongo. How to disable them?

                  我的配置包含以下依赖项:

                  My config contains following dependencies:

                  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 ...

                  i.e. I have removed org.springframework.boot:spring-boot-starter-data-mongodb and was thinking will use Mongo myself...

                  更新2

                  我发现了相关问题:如何禁用弹簧-data-mongodb 在 spring-boot 中自动配置

                  推荐答案

                  我要在我的主注释类中添加排除注释,

                  I was to add exclusion annotation to my main annotated class,

                  即而不是

                  @SpringBootApplication
                  

                  我应该有

                  @SpringBootApplication
                  @EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
                  

                  这篇关于使用 Java 访问 MongoDB 时连接到服务器 localhost:27017 时监控线程出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:onSave()(对于使用 Hibernate/Spring Data Repositories 保存的任何实体) 下一篇:&lt;S 扩展 T&gt; 是什么意思保存(S实体);在 Spring 存储库中?

                  相关文章

                    <bdo id='HP7ko'></bdo><ul id='HP7ko'></ul>
                1. <legend id='HP7ko'><style id='HP7ko'><dir id='HP7ko'><q id='HP7ko'></q></dir></style></legend>
                  <i id='HP7ko'><tr id='HP7ko'><dt id='HP7ko'><q id='HP7ko'><span id='HP7ko'><b id='HP7ko'><form id='HP7ko'><ins id='HP7ko'></ins><ul id='HP7ko'></ul><sub id='HP7ko'></sub></form><legend id='HP7ko'></legend><bdo id='HP7ko'><pre id='HP7ko'><center id='HP7ko'></center></pre></bdo></b><th id='HP7ko'></th></span></q></dt></tr></i><div id='HP7ko'><tfoot id='HP7ko'></tfoot><dl id='HP7ko'><fieldset id='HP7ko'></fieldset></dl></div>

                  <small id='HP7ko'></small><noframes id='HP7ko'>

                  <tfoot id='HP7ko'></tfoot>