我已经在Spring Boot中实现了Elasticsearch。每次重新启动服务器时,都会出现以下错误。
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productController': Unsatisfied dependency expressed through field 'ps'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productServiceImpl': Unsatisfied dependency expressed through field 'pr'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Rejecting mapping update to [products] as the final mapping would have more than 1 type: [_doc, product]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
我每次启动服务器后都删除了索引,然后执行索引。谁能给我建议解决方案
最佳答案
每个索引的Elasticsearch v6及更高版本不能具有多个类型。但是从您的异常来看,您的映射试图在索引上创建多个类型(_doc和product)
有关更多信息,请引用https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html。
关于spring-boot - Elasticsearch在启动期间引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61974572/