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)