Mr.*_*iik 5 spring mongodb spring-data spring-data-mongodb spring-boot
在以前的 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=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" }
Run Code Online (Sandbox Code Playgroud)
我进行了搜索,但没有找到任何方法来修复它。除此之外,我在日志中还有消息:
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.
Run Code Online (Sandbox Code Playgroud)
但正如我在这里读到的,这并不那么重要。此外,此日志消息看起来也不重要:
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
Run Code Online (Sandbox Code Playgroud)
因为我已添加spring.data.mongodb.auto-index-creation: true
到我的application.yml
,但该消息仍然存在,因为它没有任何标志检查。
我尝试降级spring-data-mongo
(以及boot-starter
),但它无法配置ClassNotFound
异常的上下文。
有人遇到过这个问题吗?怎么解决呢?
归档时间: |
|
查看次数: |
1812 次 |
最近记录: |