question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Legacy MongoClient conflict when declared explicitly as Bean

See original GitHub issue

I am working on a spring boot project with JaVers integrated along with spring-boot-starter-data-mongodb.

I had to configure MongoClient for some encryption settings for which I need to explicitly create it as a Bean. The newer version of mongo java driver (since version 3.7) recommends that the MongoClient is created using MongoClients class which creates an instance of com.mongodb.client.MongoClient (source). When this happens, the application produces an error as JaVers is expecting a legacy version of MongoClient.

Field mongoClient in org.javers.spring.boot.mongo.JaversMongoAutoConfiguration required a bean of type 'com.mongodb.MongoClient' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)

The following candidates were found but could not be injected:
	- Bean method 'mongo' in 'MongoAutoConfiguration' not loaded because @ConditionalOnMissingBean (types: com.mongodb.MongoClient,com.mongodb.client.MongoClient; SearchStrategy: all) found beans of type 'com.mongodb.client.MongoClient' mongoClient


Action:

Consider revisiting the entries above or defining a bean of type 'com.mongodb.MongoClient' in your configuration.

This forces me to stay with the legacy MongoClient that doesn’t have a nice builder to accept various settings.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bartoszwalacikcommented, May 3, 2020

released in 5.9.0

0reactions
bartoszwalacikcommented, May 3, 2020

Ok, so for now, dedicated MongoClient config will be based on the new com.mongodb.client.MongoClientAPI and default MongoClient config will be based on the old API as Spring Boot wants. I will relese these changes in 5.9.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I @Autowire a spring bean that was created from an ...
I have a module/jar that I've created and am using as a util library. I created a service in there like so: @Service...
Read more >
Conversion from mongodb-driver-legacy to mongodb-driver ...
Is there any documentation that discusses converting an existing application from the mongodb-driver-legacy to the mongodb-driver-sync ...
Read more >
Spring Data MongoDB - Reference Documentation
It looks up a declared query first, and, if no declared query is found, it creates a custom method name-based query. This is...
Read more >
Release notes — JaVers Documentation
@Bean JaversBuilderPlugin javersBuilderPlugin() { return builder -> builder . ... If you have explicit dependency to org.mongodb:mongo-java-driver:3.x ...
Read more >
GORM for Hibernate - Grails
Unified Multiple Data Sources support for Hibernate, MongoDB and Neo4j ... If you want to continue to use Hibernate 4 you must explicitly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found