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 mongoconfiguration.java configuration class, and then you can connect it. Next, enjoy mongotemplate
@Configuration
public class MongoConfiguration {
@Value("${spring.data.mongodb.uri}")
private String mongodbUri;
@Value("${spring.data.mongodb.option.min-connection-per-host}")
private Integer minConnectionPerHost;
@Value("${spring.data.mongodb.option.max-connection-per-host}")
private Integer maxConnectionPerHost;
@Bean
public MongoTemplate mongoTemplate() throws Exception {
MongoClientOptions.Builder builder = new Builder();
builder.minConnectionsPerHost(minConnectionPerHost);
builder.connectionsPerHost(maxConnectionPerHost);
final SimpleMongoDbFactory simpleMongoDbFactory = new SimpleMongoDbFactory(new MongoClientURI(mongodbUri, builder));
MongoTemplate mongoTemplate = new MongoTemplate(simpleMongoDbFactory);
return mongoTemplate;
}
}
Read More:
- Spring boot integrates Mongo to solve some common connection and permission problems. Docker compose installs Mongo
- Error: could’t connect to server 127.0.0.1:27017 Src / Mongo / shell/ mongo.js
- Mongodb uses Mongo to report error: could’t connect to server 127.0.0.1:27017, connection attempt failed: socket
- Windows_ Win7 broadband connection prompt remote access connection manager error
- Vscode remote connection server reports an error: could not establish connection to “XXXXXX” [resolved]
- remote: error: GH007: Your push would publish a private email address.
- MySQL local connection Error 1130_ The solution of MySQL 1130 error report when remote connection through Navicat for MySQL
- Navicat remote connection SQL Server 2014 express report 08001 error
- Remote connection MySQL error 1045 solution
- Authentication error occurred on remote connection, the required function is not supported
- Error 711: Cannot load Remote Access Service Connection Manager.
- SQL server remote computer refused network connection, error: 1225, specific solution steps.
- Failed to connect to remote VM. Connection reused. Connection reused: Connect
- An authentication error occurred in the remote desktop connection
- An error is reported when starting the Remote Access Connection Manager service
- Microsoft Remote Desktop (Android version) connection appears the solution of the error of 0x204
- “2003” error reported by sqlyog for Linux remote connection solution
- The remote host closed the connection. The error code is 0x80072746.
- Remote sshd prompt: server unexpectedly closed network connection
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”