Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method ‘mongo‘ threw exception; nested exception is java.lang.IllegalArgumentException: clusterListener can not be null at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] ... 18 common frames omitted Caused by: java.lang.IllegalArgumentException: clusterListener can not be null at com.mongodb.assertions.Assertions.notNull(Assertions.java:37) ~[mongodb-driver-core-3.6.4.jar:na] at com.mongodb.connection.ClusterSettings$Builder.addClusterListener(ClusterSettings.java:218) ~[mongodb-driver-core-3.6.4.jar:na] at com.mongodb.connection.DefaultClusterFactory.getClusterSettings(DefaultClusterFactory.java:190) ~[mongodb-driver-core-3.6.4.jar:na] at com.mongodb.connection.DefaultClusterFactory.create(DefaultClusterFactory.java:80) ~[mongodb-driver-core-3.6.4.jar:na] at com.mongodb.Mongo.createCluster(Mongo.java:682) ~[mongodb-driver-3.2.2.jar:na] at com.mongodb.Mongo.createCluster(Mongo.java:668) ~[mongodb-driver-3.2.2.jar:na] at com.mongodb.Mongo.createCluster(Mongo.java:642) ~[mongodb-driver-3.2.2.jar:na] at com.mongodb.Mongo.<init>(Mongo.java:289) ~[mongodb-driver-3.2.2.jar:na] at com.mongodb.MongoClient.<init>(MongoClient.java:268) ~[mongodb-driver-3.2.2.jar:na] at org.springframework.boot.autoconfigure.mongo.MongoClientFactory.createMongoClient(MongoClientFactory.java:111) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.autoconfigure.mongo.MongoClientFactory.createNetworkMongoClient(MongoClientFactory.java:107) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.autoconfigure.mongo.MongoClientFactory.createMongoClient(MongoClientFactory.java:67) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.mongo(MongoAutoConfiguration.java:70) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration$$EnhancerBySpringCGLIB$$634858fd.CGLIB$mongo$1(<generated>) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration$$EnhancerBySpringCGLIB$$634858fd$$FastClassBySpringCGLIB$$85823a2.invoke(<generated>) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration$$EnhancerBySpringCGLIB$$634858fd.mongo(<generated>) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] ... 19 common frames omitted
查看 pom依赖 <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver</artifactId> <version>3.2.2</version> </dependency>
将依赖改为3.6版本就解决Exception
原文地址:https://www.cnblogs.com/oldzhang1222/p/9543715.html
时间: 2024-10-10 14:24:08