0

So the current version does not use spring-data-mongodb 2.1.0 which I need to use ..

The problem is every-time i simply override the dependency in the POM by adding

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-mongodb</artifactId>
    <version>2.1.1.RELEASE</version>
</dependency>

I end up getting a compile error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]: Factory method 'healthEndpoint' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.mongo.MongoHealthIndicatorConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mappingMongoConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mappingMongoConverter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.mapping.context.AbstractMappingContext.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V

2
  • 1
    Why do you need to use spring-data-mongodb 2.1.0? Commented Oct 29, 2018 at 12:59
  • @Boris Transactional Operations Commented Oct 29, 2018 at 13:31

4 Answers 4

4

Quote from Spring Boot in Action book, p.37:

...take caution when overriding the dependencies that are pulled in transitively by Spring Boot starter dependencies. Although different versions may work fine, there’s a great amount of comfort that can be taken knowing that the versions chosen by the starters have been tested to play well together. You should only override these transitive dependencies under special circumstances (such as a bug fix in a newer version).

I personally would not take such a risk of overriding the spring-data-mongodb version.

If you really need to use the latest version of spring-data-mongodb I recommend upgrading the version of Spring Boot to 2.1.0.

Sign up to request clarification or add additional context in comments.

10 Comments

Please look at my answer. The version he'd like to use is not available in spring-boot by now.
The whole reason of Springboot is convenience. Thanks for this post because it is absolutely clear, from my own experiences with Springboot that convenience has a price to pay. What would be great, is to be able to then ditch convenience and create a Spring project that allows for the desired MongoDb dependency to be possible; which is to say the SpringData capabilities with the MongoDb version desired in the orig. post.
Maybe this would be helpful for a non-SpringBoot barebones implementation ? baeldung.com/spring-data-mongodb-tutorial
@Beezer Nope that didn't work .. I believe it is because this is not using boot :)
I just tried it and @Boris is right...with the 2.1.0 version and the JPA and mongodb flavours the demo project contains the 2.1.2 of the spring-data-mongodb...which is one revision above what the original question wanted, but I am guessing it is good enough...i will add the pictures to an answer, but I dont want points, Boris deserves the points and I will up vote his response.
|
1

As per @Boris answer, if you do the following you can prove that he is correct. Go here: https://start.spring.io/ Select the following: enter image description here

Create the project demo. If you then expand and import into Intellij, and then get the effective POM and search for the original requirement you will find this which is one revision above the original asked. What would be great is if there is a site that shows all the combinations of revisions for a version of Spring boot...if anyone knows please add to this. Thanks. enter image description here

Comments

0

The API of AbstractMappingContext has changed in newer versions and therefore is not compatible with your current spring-boot version.

I suggest you upgrade the whole spring-boot version to that one version that fits your desired spring-data-mongo version.

EDIT:

I'm afraid there is not spring-boot support for the 2.1.1 version yet. The newest one is 2.0.6.RELEASE that uses org.springframework.data:spring-data-mongodb:2.0.11.RELEASE

2 Comments

Yeah I saw the 2.0.6 release and its dependencies, thats why I was trying to override them and use 2.1.0
I got it to compile .. but I get runtime errors on documents insertion. I will just then wait for the official release. Indeed it seems a risky business updating each dependency on it's own.
0

I also encountered this problem, it seems that in the low version of the spring boot can not be resolved, because MongoTransactionManager requires spring-data-mongodb version is greater than 2.1.0, and my org.springframework.data only 2.0.6.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.