1

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.

veera
  • 317
  • 2
  • 3
  • 14

2 Answers2

2

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.

  • Is there any page or documentation from where we can identify which spring-data-cosmos version is compatible with which Spring Boot version? @Kushagra In changelog.md it is mentioned that spring-data-cosmos 3.5.0 version supports spring-boot version 2.4.3. So can we know from anywhere which spring-data-cosmos supports older spring-boot version? – rns Mar 17 '22 at 04:55
  • Yes, for every version of azure-spring-data-cosmos, we do mention the compatible version of spring-boot in the changelog - https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos/CHANGELOG.md – Kushagra Thapar Mar 18 '22 at 14:40
  • Also, maven repository can be another way to figure out the compatible versions - like here -> https://mvnrepository.com/artifact/com.azure/azure-spring-data-cosmos/3.19.0 spring-data-cosmos 3.19.0 is compatible with below spring versions -> org.springframework » spring-core 5.3.15 org.springframework » spring-web 5.3.15 org.springframework » spring-beans 5.3.15 org.springframework » spring-context 5.3.15 org.springframework » spring-tx 5.3.15 org.springframework » spring-expression 5.3.15 org.springframework.data » spring-data-commons 2.6.1 – Kushagra Thapar Mar 18 '22 at 14:43
0

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

Ashish Patil
  • 4,428
  • 1
  • 15
  • 36