你可以的,加油

IDEA中使用RestHighLevelClient出现包里的属性和方法不能引用

Elasticsearch | 作者 Amir | 发布于2019年10月18日 | 阅读数:3680

在IDEA中调用RestHighLevelClient,Maven依赖已经导入,但是实例化IndexRequest时出现了问题。首先是定义的indexRequest实例不能智能补全和识别,就算自己输入了实例的变量名,也无法使用方法。详情看图片以及图片描述。
 
IDEA使用2019.2.3版本,ES使用7.2.0版本,已在pom里添加依赖,且资源下载成功。jdk1.8-221u

4.png

图一显示上一行定义的indexRequest无法智能补全,
 

1.png

图二显示自己补全了变量名再调用id方法显示id是私有的
 
 

3.png


4.png

图三图四显示虽然id属性是私有的,但id()方法公有,为什么不能识别和调用?
 
这个是IDEA的bug还是我哪里有疏忽?
 
之前在Eclipse中也有使用,没有出现类似问题,都是正常调用的。
 
import org.apache.http.HttpHost;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

public class Test1 {

RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost("amir1", 9200, "http"),
new HttpHost("amir1", 9200, "http")
)
);
//amir1 是我虚拟机的host映射
IndexRequest indexRequest = new IndexRequest("testdata");
indexRequest.id("1");
}
已邀请:

要回复问题请先登录注册