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);
> }
> -----------------------------------------------------------------------------------------
1、看提示的原因是springBoot2.2.0之后自动创建index不再被推荐使用
2、在message类中默认自动创建index,所以导致了报错
3、解决办法
在yml文件中添加
spring:
data:
mongodb:
auto-index-creation: false
这样就没问题了