MongoDB not working after upgrading spring boot plugin from 2.2.6.RELEASE to 2.3.4.RELEASE

Viewed 323

I have requirement to upgrade the "spring-boot-gradle-plugin" version

From : 2.2.6.RELEASE

To : 2.3.4.RELEASE

MongoDB Issue

I have updated "MongoClientOptions" to "MongoClientSettings" and created a new Mongoclient like below,

@Override public MongoClient mongoClient() {

MongoClientSettings mongoClientSettings = MongoClientSettings.builder() .credential(getCredential()) .applyToClusterSettings(b -> b.hosts(getServerList())) .build();

return createMongoClient(mongoClientSettings);

}

Build is getting successful, however when I bring up the application, getting below exception

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTemplate' defined in class path resource [MongoConfig.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory' defined in class path resource [MongoConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.MongoDatabaseFactory]: Factory method 'mongoDbFactory' threw exception; nested exception is java.lang.NoSuchFieldError: UNSPECIFIED at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject

Please note, "spring-boot-starter-data-mongodb" is there in classpath.

0 Answers
Related