具体报错信息是这样的
执行添加的功能时
Unable to parse response body for Response{requestLine=POST /article/_doc?timeout=1m HTTP/1.1, host=http://106.52.65.18:9200, response=HTTP/1.1 201 Created}; nested exception is java.lang.RuntimeException: Unable to parse response body for Response{requestLine=POST /article/_doc?timeout=1m HTTP/1.1, host=http://106.52.65.18:9200, response=HTTP/1.1 201 Created}
原因是因为es服务器的响应程序解析不了,有可能是spring-boot版本低了,没有做这方面的处理,我的es是8.0版本的,但是数据是能保存进es的,而且es那边也不报错,所以我干脆在添加的方法上做个try{}catch(){},捕捉异常处理,代码如下:
try{
repository.save(e);
}catch (Exception exception){
if(!(exception.getMessage()).contains("Created")){
throw exception;
}
}