log4j dep exclusion
This commit is contained in:
parent
913dce9225
commit
f928248447
@ -181,6 +181,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-to-slf4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
6
pom.xml
6
pom.xml
@ -261,6 +261,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-to-slf4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@ -26,8 +26,8 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
|||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
import org.apache.http.ssl.SSLContextBuilder;
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -36,6 +36,7 @@ import java.io.PrintWriter;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,18 +51,17 @@ public class HttpUtils {
|
|||||||
*/
|
*/
|
||||||
private static PoolingHttpClientConnectionManager poolConnManager = null;
|
private static PoolingHttpClientConnectionManager poolConnManager = null;
|
||||||
|
|
||||||
private static Logger logger = LogManager.getLogger(HttpUtils.class);
|
|
||||||
|
|
||||||
private static CloseableHttpClient httpClient = null;
|
private static CloseableHttpClient httpClient = null;
|
||||||
/**
|
/**
|
||||||
* 请求器的配置
|
* 请求器的配置
|
||||||
*/
|
*/
|
||||||
private static RequestConfig requestConfig;
|
private static RequestConfig requestConfig;
|
||||||
|
|
||||||
|
static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
System.out.println("httpClient~~~开始");
|
logger.info("httpClient init...");
|
||||||
SSLContextBuilder builder = new SSLContextBuilder();
|
SSLContextBuilder builder = new SSLContextBuilder();
|
||||||
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
|
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
|
||||||
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
|
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
|
||||||
@ -84,7 +84,7 @@ public class HttpUtils {
|
|||||||
connectTimeout).build();
|
connectTimeout).build();
|
||||||
// 初始化httpClient
|
// 初始化httpClient
|
||||||
httpClient = getConnection();
|
httpClient = getConnection();
|
||||||
System.out.println("初始化HttpClient~~~结束");
|
System.out.println("HttpClient inited.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -448,15 +448,16 @@ public class HttpUtils {
|
|||||||
}
|
}
|
||||||
connection.connect();
|
connection.connect();
|
||||||
//OutputStream out = new DataOutputStream(connection.getOutputStream());
|
//OutputStream out = new DataOutputStream(connection.getOutputStream());
|
||||||
PrintWriter out = new PrintWriter(new OutputStreamWriter(connection.getOutputStream(), "UTF-8"));
|
PrintWriter out = new PrintWriter(new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8));
|
||||||
out.print(formSB.toString());
|
out.print(formSB);
|
||||||
out.flush();
|
out.flush();
|
||||||
//获得响应状态
|
//获得响应状态
|
||||||
int resultCode = connection.getResponseCode();
|
int resultCode = connection.getResponseCode();
|
||||||
if (HttpURLConnection.HTTP_OK == resultCode) {
|
if (HttpURLConnection.HTTP_OK == resultCode) {
|
||||||
formSB = new StringBuffer();
|
formSB = new StringBuffer();
|
||||||
String readLine;
|
String readLine;
|
||||||
BufferedReader responseReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
BufferedReader responseReader = new BufferedReader(new InputStreamReader(connection.getInputStream(),
|
||||||
|
StandardCharsets.UTF_8));
|
||||||
while ((readLine = responseReader.readLine()) != null) {
|
while ((readLine = responseReader.readLine()) != null) {
|
||||||
formSB.append(readLine).append("\n");
|
formSB.append(readLine).append("\n");
|
||||||
}
|
}
|
||||||
@ -506,7 +507,7 @@ public class HttpUtils {
|
|||||||
}
|
}
|
||||||
// 定义 BufferedReader输入流来读取URL的响应
|
// 定义 BufferedReader输入流来读取URL的响应
|
||||||
in = new BufferedReader(new InputStreamReader(
|
in = new BufferedReader(new InputStreamReader(
|
||||||
connection.getInputStream(), "utf-8"));
|
connection.getInputStream(), StandardCharsets.UTF_8));
|
||||||
String line;
|
String line;
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
result += line;
|
result += line;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user