在整合springboot和elasticsearch時,使用spring data進行添加數據時,報錯:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource
[org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:
Factory method 'requestMappingHandlerAdapter' threw exception;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.springframework.format.support.FormattingConversionService]:
Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]:
Constructor threw exception; nested exception is java.lang.IllegalArgumentException:
Rejecting mapping update to [****] as the final mapping would have more than 1 type: [***, *****]
原因:
Elasticsearch 6.0 一個索引只允許有一個type;