Skip to content
This repository was archived by the owner on Jan 10, 2022. It is now read-only.
This repository was archived by the owner on Jan 10, 2022. It is now read-only.

rework mongodb index creation in spring data 3.x #5

Description

@basalt79
2020-03-14 08:37:27.725  WARN 16540 --- [           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);
	> }
	> -----------------------------------------------------------------------------------------

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions