I have the following Spring Boot configuration class so that an index is created in our MongoDB:
@Configuration @DependsOn("mongoTemplate") @Profile({ &