Springboot+mongodb error caused By:java.net.ConnectException:Connection refused (Connection refused)

Source: Internet
Author: User
Tags spring initializr

Com.mongodb.MongoSocketOpenException:Exception Opening socket

At Com.mongodb.connection.SocketStream.open (socketstream.java:63) ~[mongodb-driver-core-3.4.3.jar:na]
At Com.mongodb.connection.InternalStreamConnection.open (internalstreamconnection.java:115) ~[ Mongodb-driver-core-3.4.3.jar:na]
At Com.mongodb.connection.defaultservermonitor$servermonitorrunnable.run (defaultservermonitor.java:113) ~[ Mongodb-driver-core-3.4.3.jar:na]
At Java.lang.Thread.run (thread.java:748) [na:1.8.0_161]


caused By:java.net.ConnectException:Connection refused:connect
At Java.net.DualStackPlainSocketImpl.waitForConnect (Native Method) ~[na:1.8.0_161]
At Java.net.DualStackPlainSocketImpl.socketConnect (dualstackplainsocketimpl.java:85) ~[na:1.8.0_161]
At Java.net.AbstractPlainSocketImpl.doConnect (abstractplainsocketimpl.java:350) ~[na:1.8.0_161]
At Java.net.AbstractPlainSocketImpl.connectToAddress (abstractplainsocketimpl.java:206) ~[na:1.8.0_161]
At Java.net.AbstractPlainSocketImpl.connect (abstractplainsocketimpl.java:188) ~[na:1.8.0_161]
At Java.net.PlainSocketImpl.connect (plainsocketimpl.java:172) ~[na:1.8.0_161]
At Java.net.SocksSocketImpl.connect (sockssocketimpl.java:392) ~[na:1.8.0_161]
At Java.net.Socket.connect (socket.java:589) ~[na:1.8.0_161]
At Com.mongodb.connection.SocketStreamHelper.initialize (socketstreamhelper.java:57) ~[ Mongodb-driver-core-3.4.3.jar:na]
At Com.mongodb.connection.SocketStream.open (socketstream.java:58) ~[mongodb-driver-core-3.4.3.jar:na]
... 3 Common frames omitted

Search the web for solutions

1. Said to be springboot automatically configured to support MongoDB. An MONGO instance is automatically instantiated when Springboot is started. To add
@SpringBootApplication (exclude = Mongoautoconfiguration.class), but I do not, the original link is as follows.

http://blog.csdn.net/xuyw10000/article/details/72918360

2. Say in the configuration file to cancel the initial MongoDB (do not know how to cancel)

. http://www.cnblogs.com/zhuangfei/p/7338488.html

3. Finally found that I used the idea,spring initializr choice of dependence is testcompile, in the operating environment without

This is the default springboot.

Testcompile ('de.flapdoodle.embed:de.flapdoodle.embed.mongo')

Packaged as a jar to run an error under Linux

Change into

Compile ('de.flapdoodle.embed:de.flapdoodle.embed.mongo')

Normal operation

Springboot+mongodb error caused By:java.net.ConnectException:Connection refused (Connection refused)

Related Article

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.