Closed gcdelgado closed 10 months ago
@gcdelgado i guess that this is some kind of dependency version stuff.. maybe some dependency is missing or more than one version of the same dependency is present.. (for the later i use the maven enforcer plugin).. your IDE should show you your current class path and this way you can check if the class should be present.
@gcdelgado still an issue? reopen if needed..
I'm using this dependency with spring-boot 2.7.9:
And:
But the error below persists on running Junit 4 tests. What might be missing?
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: Factory method 'mongo' threw exception; nested exception is java.lang.NoClassDefFoundError: com/mongodb/connection/DefaultClusterFactory at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ... 111 more Caused by: java.lang.NoClassDefFoundError: com/mongodb/connection/DefaultClusterFactory at com.mongodb.client.internal.MongoClientImpl.createCluster(MongoClientImpl.java:201) at com.mongodb.client.internal.MongoClientImpl.(MongoClientImpl.java:61)
at com.mongodb.client.MongoClients.create(MongoClients.java:114)
at org.springframework.boot.autoconfigure.mongo.MongoClientFactorySupport.createMongoClient(MongoClientFactorySupport.java:50)
at org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.mongo(MongoAutoConfiguration.java:56)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 112 more
Caused by: java.lang.ClassNotFoundException: com.mongodb.connection.DefaultClusterFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)