Legacy MongoClient conflict when declared explicitly as Bean
See original GitHub issueI 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:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

released in 5.9.0
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