Need input how to auto create Index with spring boot application connecting with Azure Cosmos DB(Mongo API). Application Details

Below are dependencies defined buildscript {

ext { springBootVersion = '2.0.0.RELEASE' } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } }

implementation 'org.springframework.boot:spring-boot-starter-undertow' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' implementation 'org.springframework.boot:spring-boot-starter-cloud-connectors' implementation 'org.springframework.boot:spring-boot-starter-data-rest' implementation 'org.springframework.cloud:spring-cloud-starter-config:2.0.0.RELEASE' Mongo DB driver

implementation ('org.mongodb:mongo-java-driver:3.4.2') {

force = true

}

In the pojo model, annotate @indexed on the property(for which, index to be created) and model is decorated with @document. No explicit code for mapping or creating the document.

`public class MongoConfiguration extends AbstractCloudConfig {

@Bean public MongoDbFactory mongoDbFactory() {

return connectionFactory().mongoDbFactory();

}

}`

What changes are required to enable the index creation. Any suggestions would be great help.

Comment From: wilkinsona

As of 3 April 2019, Spring Boot 2.0.x is no longer support. I would recommend upgrading to a supported version of Spring Boot, ideally 2.3.x. Also, Spring Data MongoDB is a separate project. If upgrading Spring Boot (and therefore Spring Data MongoDB) does not help you to resolve your issue, please refer to Spring Data MongoDB's README to learn how to get some help.