spring An error was reported when the boot project started to connect mongodb.
2021-06-09 17:10:34,663 INFO org.mongodb.driver.cluster - Exception in monitor thread while connecting to server node1:27017 com.mongodb.MongoSocketException: node1 at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211) at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75) at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) at java.lang.Thread.run(Thread.java:745) Caused by: java.net.UnknownHostException: node1 at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) at java.net.InetAddress.getAllByName0(InetAddress.java:1276) at java.net.InetAddress.getAllByName(InetAddress.java:1192) at java.net.InetAddress.getAllByName(InetAddress.java:1126) at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:203) ... 5 common frames omitted
Because it’s a new project, Mongo library belongs to other projects. This is just a test application. So the first doubt is that the project version driver is not compatible with mongodb library. After replacing other versions of mongodb library, it is OK.
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> <version>2.1.3.RELEASE</version> </dependency>
Because of spring Mongodb driver is also the official driver of encapsulated mongodb. When you enter the spring data mongodb project, you can see that the official version of mongodb driver is 3.8.2
Then go to the official website of mongodb to see that version 3.8 supports version 4.0 database at most. I started testing with the 4.2 library (Official website https://docs.mongodb.com/drivers/java/)
So that’s it.
- Mybatis idea environment integration jar package
- Springboot integrated with mybatis
- MongoNetworkError: failed to connect to server [localhost:27017]
- Error parsing lifecycle processing instructions
- ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing…..
- Error processing condition on org.springframework.boot . autoconfigure.context.Property Error report solution
- Integration openfeign failed to start
- After Nacos started, the client worker log was printed all the time
- Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build Exception caught: basedir src/mai
- Update project manually_ Solution of too large jar package in springboot
- [Fixed]No bean named ‘sqlSessionFactoryBean’ available
- Solution to the failure of springboot integrated PageHelper
- Could not create connection to database server. Attempted reconnect 3 times. Giving
- Springboot: start error reporting after introducing paging plug-in PageHelper
- Caused by: java.lang.ClassNotFoundException: com.alibaba.nacos.api.naming.NamingMaintainService
- Springboot startup error: java.lang.IllegalArgumentException : Property ‘sqlSessionFactory’ or ‘sqlSessionTempla
- Solve the problem that dbvisualizer cannot connect to mysql8
- [Solved] Import org.apache.hadoop.hbase.hbaseconfiguration package cannot be imported
- events.js:160 throw er; // Unhandled ‘error’ event ^ Error: write after end at Serv
- Spring boot problem 1: error reporting life processing instructions for building a spring boot project