赞
踩
(1)新建工程项目
(2)选择maven类型
(3)输入名称
(4)确认maven安装路径
(5)项目路径
(6)构建maven工程
(7)构建完成
参考官网,编写pom.xml
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_maven_repository.html
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.hadron</groupId>
<artifactId>esapi</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>esapi</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/transport -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
(1)在maven项目的/src/main目录下新建resources目录(与java同级别),然后右键单击resources目录,选择“Mark Directory As”,并设置为Resources Root。
(2)在resources目录下新建log4j2.properties文件,编辑内容如下。
appender.console.type = console
appender.console.name = console
appender.console.layout.type = PatternLayout
rootLogger.level = info
rootLogger.appenderRef.console.ref =console
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。