Spring boot 2.2.4 release is not compatible with azure spring data cosmos 3.x.x

782 Views Asked by At

I'm working on springboot with cosmos api,So if i use @Query that is provided by azure-spring-data-cosmos library(3.x.x) with Springboot 2.5.0 able to get the results from cosmos database. But if i use the same azure-spring-data-cosmos library(3.x.x) with springboot 2.2.4 getting below exception

Field userRepository in com.example.service.UserService required a bean of type 'com.example.repository.UserRepository' that could not be found.The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:Consider defining a bean of type 'com.example.repository.UserRepository' in your configuration.

2

There are 2 best solutions below

0
On

Not sure which version of cosmos you are using but cosmos change log clearly mentions that 3.5.0 has spring boot support 2.4.3 & above.

Please check if your cosmos version is 3.5.0 which might be causing this issue.

Reference link : https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos/CHANGELOG.md#350-2021-03-11

3
On

I would highly recommend using the latest azure-spring-data-cosmos SDK version 3.19.0 - https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos/CHANGELOG.md#3190-2022-03-10

Since spring boot releases one major version every 6 months, azure spring team supports last 2 versions of Spring Boot. We currently support spring boot 2.5.x and 2.6.x. You should be able to use any one of these versions of spring-boot with latest version of azure-spring-data-cosmos SDK.

The changelog points to the compatible version of spring boot which can be used with azure-spring-data-cosmos SDK.

Also, spring-boot 2.2.4 is more than 2 years old at this point of time. We don't support it anymore.