Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-2435

MongoPersistentEntityIndexCreator should not warn when auto-index-creation property is set

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.2.3 (Moore SR3)
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      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 a @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:

      Example in Spring-Boot:

      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 explicitly.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cstrobl Christoph Strobl
              Reporter:
              jochenchrist Jochen Christ
              Last updater:
              Mark Paluch
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: