使用环境:IDEA、Maven
创建maven工程进行API的使用
pom依赖:
junit junit 4.12 test org.elasticsearch.client transport 6.1.1 org.elasticsearch elasticsearch 6.1.1 org.apache.logging.log4j log4j-core 2.9.1
注意:完成上述操作后既可以正常编写ElasticSearchAPI了,运行的时候会出现以下异常
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.
出现该异常的原因:缺少ElasticSearch的log4j2.properties文件。
解决方法:在maven工程的resources目录中新建一个文件命名为“log4j2.properties”,文件中添加以下内容
appender.console.type = Consoleappender.console.name = consoleappender.console.layout.type = PatternLayoutappender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%m%nrootLogger.level = inforootLogger.appenderRef.console.ref = console
如此ElasticSearch6.X的JavaAPI环境部署成功!
Linux部署ElasticSearch集群:安装Elasticsearch及其遇到的坑
ElasticSearch的Chrome的插件安装:安装elasticsearch-head.crx插件