When starting a fresh Spring Boot 2.2.1 application with Spring Data MongoDB support, then the warning appears, as soon a @Document is created with one @Index.

2019-12-04 18:52:52.161  WARN 94633 --- [           main] .m.c.i.MongoPersistentEntityIndexCreator : Automatic index creation will be disabled by default as of Spring Data MongoDB 3.x.
    Please use 'MongoMappingContext#setAutoIndexCreation(boolean)' or override 'MongoConfigurationSupport#autoIndexCreation()' to be explicit.
    However, we recommend setting up indices manually in an application ready block. You may use index derivation there as well.

    > -----------------------------------------------------------------------------------------
    > @EventListener(ApplicationReadyEvent.class)
    > public void initIndicesAfterStartup() {
    >
    >     IndexOperations indexOps = mongoTemplate.indexOps(DomainType.class);
    >
    >     IndexResolver resolver = new MongoPersistentEntityIndexResolver(mongoMappingContext);
    >     resolver.resolveIndexFor(DomainType.class).forEach(indexOps::ensureIndex);
    > }
    > -----------------------------------------------------------------------------------------

As the log suggest, it is now possible to explicitly enable or disable auto index creation with the property:

spring.data.mongodb.auto-index-creation=true

However, the warning still appears. Should be changed to not show the warning, once the property is set.

Comment From: wilkinsona

Thanks for the suggestion. Your proposal would have to be implemented in Spring Data MongoDB, perhaps by tracking whether setAutoIndexCreation(true) has been called. They use JIRA for issue tracking. If you'd like to pursue this, you can make the suggestion here.

Comment From: javaHelper

I set the spring.data.mongodb.auto-index-creation=true but still warning is not going away. Error log here: https://stackoverflow.com/questions/60003179/please-use-mongomappingcontextsetautoindexcreationboolean-or-override-mong

Comment From: wilkinsona

@javaHelper That's the problem described above. As noted in my response, I believe a fix needs to be made in Spring Data MongoDB. If you would like to see that happen, please open a JIRA ticket.

/cc @mp911de

Comment From: ArnauAregall

@wilkinsona is already open: https://jira.spring.io/browse/DATAMONGO-2435