【发布时间】:2021-08-05 06:59:32
【问题描述】:
我正在尝试在同一个应用程序中同时配置 morphia 和 mongotemplate。我在 pom.xml 中添加了以下依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>1.3.2</version>
</dependency>
当我运行应用程序时,我收到以下错误,因为两个依赖项都有 mongo 驱动程序。
该方法的类 com.mongodb.ConnectionString 可从以下位置获得:
jar:file:/C:/Users/.m2/repository/org/mongodb/mongodb-driver-core/4.1.1/mongodb-driver-core-4.1.1.jar!/com/mongodb/ConnectionString.class
jar:file:/C:/Users/.m2/repository/org/mongodb/mongo-java-driver/3.4.0/mongo-java-driver-3.4.0.jar!/com/mongodb/ConnectionString.class
类层次结构是从以下位置加载的:
com.mongodb.ConnectionString: file:/C:/Users/.m2/repository/org/mongodb/mongodb-driver-core/4.1.1/mongodb-driver-core-4.1.1.jar
删除其中任何一个都会出现以下错误。
java.lang.IllegalArgumentException:找不到类 [com.mongodb.MongoClientSettings]
我该如何解决这个问题?提前致谢!
【问题讨论】:
标签: spring-boot morphia mongotemplate