spring引导中的Axon extensions.mongo 4.3:noSuchMethodError-com.mongodb.MongoClient

spring引导中的Axon extensions.mongo 4.3:noSuchMethodError-com.mongodb.MongoClient,mongodb,spring-boot,axon-framework,Mongodb,Spring Boot,Axon Framework,我正试图在一个带有Axon的extensions.mongo依赖项的spring boot项目上运行mvn clean install。mongo数据库在docker容器中启动并运行 在pom中,我有: <dependency> <groupId>org.axonframework.extensions.mongo</groupId> <artifactId>axon-mongo</artifactId> <

我正试图在一个带有Axon的
extensions.mongo
依赖项的spring boot项目上运行
mvn clean install
。mongo数据库在docker容器中启动并运行

在pom中,我有:

<dependency>
    <groupId>org.axonframework.extensions.mongo</groupId>
    <artifactId>axon-mongo</artifactId>
    <version>4.3</version>
</dependency>
然后,当运行
mvn clean install
时,我得到以下堆栈跟踪:

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoClient' defined in com.springbank.user.core.configuration.AxonConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method 'mongoClient' threw exception; nested exception is java.lang.NoSuchMethodError: 'com.mongodb.connection.ConnectionPoolSettings$Builder com.mongodb.connection.ConnectionPoolSettings$Builder.maxWaitQueueSize(int)'
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method 'mongoClient' threw exception; nested exception is java.lang.NoSuchMethodError: 'com.mongodb.connection.ConnectionPoolSettings$Builder com.mongodb.connection.ConnectionPoolSettings$Builder.maxWaitQueueSize(int)'
Caused by: java.lang.NoSuchMethodError: 'com.mongodb.connection.ConnectionPoolSettings$Builder com.mongodb.connection.ConnectionPoolSettings$Builder.maxWaitQueueSize(int)'

Spring Boot将在类路径上可用时自动配置
MongoClient
。您只需在
应用程序.properties
中指定适当的
spring.mongo
属性(根据配置判断,您已经使用了该属性)

因此,简单的解决方法就是删除这个
@Bean
方法


如果您确实想使用该
MongoFactory
,则需要确定哪个版本的MongoDB(本例中的Mongo客户端)与之兼容。

您使用的是不兼容的版本。另外,
mongoclient
将通过自动配置提供,因此不需要;我在另一个问题中看到,可能是这样的,但在这种情况下,兼容的版本是什么?我的意思是,是否有一个版本我可以使用,以便应用此配置?我试过其他人-降到4.1,但似乎什么都不起作用4.1什么?这看起来就像您正在使用与您正在使用的Spring Mongo版本不兼容的Mongo驱动程序。当您使用Spring Boot时,这可能意味着您对版本的处理太多了;我尝试了4.3,也尝试了其他版本(包括4.1);我想这就是你所说的不兼容版本——mongo扩展的意思。因此,基本上我尝试更改mongo驱动程序的版本,然后重试
mvn clean install
,正如前面提到的
MongoFactory
(提供该类的任何东西),它期望您当前使用的MonogDB版本的更新/旧版本。IMHO您不需要该方法,Spring Boot将自动为您配置
MongoClient
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoClient' defined in com.springbank.user.core.configuration.AxonConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method 'mongoClient' threw exception; nested exception is java.lang.NoSuchMethodError: 'com.mongodb.connection.ConnectionPoolSettings$Builder com.mongodb.connection.ConnectionPoolSettings$Builder.maxWaitQueueSize(int)'
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method 'mongoClient' threw exception; nested exception is java.lang.NoSuchMethodError: 'com.mongodb.connection.ConnectionPoolSettings$Builder com.mongodb.connection.ConnectionPoolSettings$Builder.maxWaitQueueSize(int)'
Caused by: java.lang.NoSuchMethodError: 'com.mongodb.connection.ConnectionPoolSettings$Builder com.mongodb.connection.ConnectionPoolSettings$Builder.maxWaitQueueSize(int)'