Mongo connection remote address error

The remote address is clearly configured, but it is still connected to the localhost

Error log:

[localhost:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server localhost:27017

com.mongodb.MongoSocketOpenException: Exception opening socket

terms of settlement:

1. Springboot startup class, remove these two configuration classes

@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})

2. Add configuration class, and then you can connect it. Next, enjoy mongotemplate

public class MongoConfiguration {
    private String mongodbUri;

    private Integer minConnectionPerHost;

    private Integer maxConnectionPerHost;

    public MongoTemplate mongoTemplate() throws Exception {
        MongoClientOptions.Builder builder = new Builder();
        final SimpleMongoDbFactory simpleMongoDbFactory = new SimpleMongoDbFactory(new MongoClientURI(mongodbUri, builder));
        MongoTemplate mongoTemplate = new MongoTemplate(simpleMongoDbFactory);
        return mongoTemplate;

Read More: