Exception in monitor thread while connecting to server localhost:27017 while accessing MongoDB with Java

半腔热情 提交于 2019-12-04 00:44:39

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

i.e. instead of

@SpringBootApplication

I should have

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

try adding

spring.data.mongodb.host=hostIpOnWhichMongoIsRunning spring.data.mongodb.port=27017

into application.properties. if mongo is not running on localhost, this should fix the issue.

It seems your server is not running. Also if it running, it is doing so on a different port.

Mark Bramnik

I can't say for sure. It's kind of not enough information question.

I can say that: Mongo driver by default tries to connect to the local host. Probably you haven't specified the Mongo host/port.

So you'll have to configure the MongoDB host/port/credentials (if you have those).

Maybe it's network related issue or firewall (try to connect to MongoDB from your machine directly with cli / even running a basic program that uses only mongo driver).

From the stacktrace I don't see any usage of Spring, so more information is required to say for sure.

In general you can analyze the dependencies in Gradle by using gradle dependencies command (see here).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!