Error when configuring MongoDB data source in SpringBoot

problem:

When configuring MongDB, mongo dependency is introduced

 	<!-- MongoDB依赖 -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-mongodb</artifactId>
		<version>2.3.4.RELEASE</version>
	</dependency>

The following two errors also appeared

import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
import com.mongodb.MongoClient;

Reason: The
mongo version is too new. The two jar packages in the new version have been changed or replaced, so an error will be reported.
Insert picture description here
Problem solution:
Modify the version, and the introduced MongoDB version is less than 2.0.4.

	 <!-- MongoDB依赖 -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-mongodb</artifactId>
		<version>2.0.4.RELEASE</version>
	</dependency>

Guess you like

Origin blog.csdn.net/qq_41936224/article/details/109329702