Spring 如何修复更新到Srping Boot 2.2后mongo索引的创建?
在以前版本的Spring Boot(2.1.9)上,一切正常。我已将其更新为Spring 如何修复更新到Srping Boot 2.2后mongo索引的创建?,spring,mongodb,spring-boot,spring-data,spring-data-mongodb,Spring,Mongodb,Spring Boot,Spring Data,Spring Data Mongodb,在以前版本的Spring Boot(2.1.9)上,一切正常。我已将其更新为2.2.2.RELEASE(使用了依赖项管理插件),并开始出现错误: org.springframework.dao.DataIntegrityViolationException: Cannot create index for '' in collection 'testDTO' with keys 'Document{{_id=1, version=1}}' and options 'Document{{name=
2.2.2.RELEASE
(使用了依赖项管理插件),并开始出现错误:
org.springframework.dao.DataIntegrityViolationException:
Cannot create index for '' in collection 'testDTO' with keys 'Document{{_id=1, version=1}}' and
options 'Document{{name=optimistic_concurrency_idx}}'.;
nested exception is com.mongodb.MongoCommandException:
Command failed with error 67 (CannotCreateIndex): 'Unknown index plugin '1'' on server mongo:27017.
The full response is { "ok" : 0.0, "errmsg" : "Unknown index plugin '1'", "code" : 67, "codeName" : "CannotCreateIndex" }
我已经找过了,但没有找到任何方法来修复它。
除此之外,我在日志中还有消息:
Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
但正如我所读到的,这并不重要。
此外,此日志消息看起来也不重要:
Automatic index creation will be disabled by default as of Spring Data MongoDB 3.x.\n\tPlease use 'MongoMappingContext#setAutoIndexCreation(boolean)' or override 'MongoConfigurationSupport#autoIndexCreation()' to be explicit.\n\tHowever, we recommend setting up indices manually in an application ready block. You may use index derivation there as well.\n\n\t> -----------------------------------------------------------------------------------------\n\t> @EventListener(ApplicationReadyEvent.class)\n\t> public void initIndicesAfterStartup() {\n\t>\n\t> IndexOperations indexOps = mongoTemplate.indexOps(DomainType.class);\n\t>\n\t> IndexResolver resolver = new MongoPersistentEntityIndexResolver(mongoMappingContext);\n\t> resolver.resolveIndexFor(DomainType.class).forEach(indexOps::ensureIndex);\n\t> }\n\t> -----------------------------------------------------------------------------------------\n","component":"org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator
因为我已经将spring.data.mongodb.auto-index-creation:true
添加到我的application.yml
,但是消息仍然存在,因为它没有任何标志检查
我尝试降级spring数据mongo
(以及bootstarter
),但它无法配置包含ClassNotFound
异常的上下文
有人面临过这个问题吗如何解决它?