具體報錯信息是這樣的
執(zhí)行添加的功能時文章來源:http://www.zghlxwxcb.cn/news/detail-597063.html
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服務(wù)器的響應(yīng)程序解析不了,有可能是spring-boot版本低了,沒有做這方面的處理,我的es是8.0版本的,但是數(shù)據(jù)是能保存進(jìn)es的,而且es那邊也不報錯,所以我干脆在添加的方法上做個try{}catch(){},捕捉異常處理,代碼如下:文章來源地址http://www.zghlxwxcb.cn/news/detail-597063.html
try{
repository.save(e);
}catch (Exception exception){
if(!(exception.getMessage()).contains("Created")){
throw exception;
}
}
到了這里,關(guān)于spring boot整合elasticsearch報Unable to parse response body for Response的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!