Run report mongosocketopenexception error resolution after creating Springbootdemo

Source: Internet
Author: User

On the class springbootdemoapplication, right-click Run as to select the spring Boot app and the console output error log is as follows:

Com.mongodb.MongoSocketOpenException:Exception Opening socket
At Com.mongodb.connection.SocketStream.open (socketstream.java:63) ~[mongodb-driver-core-3.4.2.jar:na]
At Com.mongodb.connection.InternalStreamConnection.open (internalstreamconnection.java:115) ~[ Mongodb-driver-core-3.4.2.jar:na]
At Com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run (defaultservermonitor.java:113) ~[ Mongodb-driver-core-3.4.2.jar:na]
At Java.lang.Thread.run (Unknown Source) [na:1.8.0_91]
caused By:java.net.ConnectException:Connection refused:connect
At Java.net.DualStackPlainSocketImpl.waitForConnect (Native Method) ~[na:1.8.0_91]
At Java.net.DualStackPlainSocketImpl.socketConnect (Unknown Source) ~[na:1.8.0_91]
At Java.net.AbstractPlainSocketImpl.doConnect (Unknown Source) ~[na:1.8.0_91]
At Java.net.AbstractPlainSocketImpl.connectToAddress (Unknown Source) ~[na:1.8.0_91]
At Java.net.AbstractPlainSocketImpl.connect (Unknown Source) ~[na:1.8.0_91]
At Java.net.PlainSocketImpl.connect (Unknown Source) ~[na:1.8.0_91]
At Java.net.SocksSocketImpl.connect (Unknown Source) ~[na:1.8.0_91]
At Java.net.Socket.connect (Unknown Source) ~[na:1.8.0_91]
At Com.mongodb.connection.SocketStreamHelper.initialize (socketstreamhelper.java:57) ~[ Mongodb-driver-core-3.4.2.jar:na]
At Com.mongodb.connection.SocketStream.open (socketstream.java:58) ~[mongodb-driver-core-3.4.2.jar:na]
... 3 Common frames omitted

Internet Baidu, found an article said that the reason is springboot automatically configured to support MongoDB. An MONGO instance is automatically instantiated when Springboot is started, and automatic configuration needs to be disabled.

Add @SpringBootApplication (exclude = Mongoautoconfiguration.class) to this note, the original link is http://blog.csdn.net/ Xuyw10000/article/details/72918360.

When I add annotations to the class, the error is resolved, but a new error log is output, as follows:

Java.lang.ClassCastException:org.springframework.boot.context.event.ApplicationFailedEvent cannot is cast to Org.springframework.boot.web.context.WebServerInitializedEvent
At Org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener ( simpleapplicationeventmulticaster.java:159) [SPRING-CONTEXT-5.0.0.RC3.JAR:5.0.0.RC3]
At Org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent ( simpleapplicationeventmulticaster.java:139) [SPRING-CONTEXT-5.0.0.RC3.JAR:5.0.0.RC3]
At Org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent ( simpleapplicationeventmulticaster.java:127) [SPRING-CONTEXT-5.0.0.RC3.JAR:5.0.0.RC3]
At Org.springframework.boot.context.event.EventPublishingRunListener.finished (Eventpublishingrunlistener.java : [SPRING-BOOT-2.0.0.M3.JAR:2.0.0.M3]
At Org.springframework.boot.SpringApplicationRunListeners.callFinishedListener ( springapplicationrunlisteners.java:79) [SPRING-BOOT-2.0.0.M3.JAR:2.0.0.M3]
At org.springframework.boot.SpringApplicationRunListeners.finished (springapplicationrunlisteners.java:72) [ SPRING-BOOT-2.0.0.M3.JAR:2.0.0.M3]
At Org.springframework.boot.SpringApplication.handleRunFailure (springapplication.java:803) [ SPRING-BOOT-2.0.0.M3.JAR:2.0.0.M3]
At Org.springframework.boot.SpringApplication.run (springapplication.java:338) [spring-boot-2.0.0.m3.jar:2.0.0.m3 ]
At Org.springframework.boot.SpringApplication.run (springapplication.java:1245) [spring-boot-2.0.0.m3.jar:2.0.0. M3]
At Org.springframework.boot.SpringApplication.run (springapplication.java:1233) [spring-boot-2.0.0.m3.jar:2.0.0. M3]
At Com.example.demo.SpringbootdemoApplication.main (springbootdemoapplication.java:22) [Classes/:na],

Copy the first line error log, search for answers on Google, need the project's Pom.xml file comment MONGO related startup statement, as follows:

<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

Restart after saving, no more error. On GitHub The original link is: https://github.com/spring-projects/spring-boot/issues/10047.

Run report mongosocketopenexception error resolution after creating Springbootdemo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.