【问题标题】:Configure morphia and mongotemplate配置morphia和mongotemplate
【发布时间】: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


    【解决方案1】:

    尝试使用使用 4.0 驱动程序的现代版 Morphia。您可以在website 上找到详细信息。当前的版本是 2.2.2,从 1.3.2 开始有许多改进和更新。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-20
      • 2015-06-04
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多