I am using Spring Rest and Mongo in Maven to make a web service that connects to a server. The problem is that I haven\'t written any code for Mongo and it is trying to conn
Spring Boot has a feature called "auto configuration". In this case, as soon as the Mongo driver is detected on the classpath, the MongoAutoConfiguration is activated with default values, which point to localhost:27017. If you don't want that behaviour, you can now either configure the properties for MongoDB (see http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-mongodb for valid property keys) or disable the MongoAutoConfiguration:
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
Spring boot throws this exception when Mongo DB is not running. Please make sure that Mongodb is running. It got resolved for me after starting Mongo DB.
for springboot, you should add following config to your application.property
spring.data.mongodb.host=localhost(your mongo server)
spring.data.mongodb.port=27017(mongo port)
In some cases, if you are using reactive you also need to remove MongoReactiveAutoConfiguration
spring:
autoconfigure:
exclude:
- org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
- org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration