起因
测试ES服务的时候,使用SpringDataES连接服务,创建索引的时候,出现如下异常
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]:
Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Could not convert [id.index] to boolean
Caused by: java.lang.IllegalArgumentException: Failed to parse value [not_analyzed] as only [true] or [false] are allowed.
原因
(前提:保证不是代码的异常,写错配置文件等,也有人说配置文件写错也会出现这个异常)
使用的版本不对,pom的SpringDataES版本为3.x,ES版本为5.x,但实际运行的服务为6.x
解决方案
修改实际ES服务的版本,因为SpringDataES更新太慢了