🎨 #4067 恢复默认 HTTP 客户端兼容性,避免非 Starter 手动集成时因默认引入 HttpClient5 导致的问题
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -162,7 +162,7 @@
|
||||
<version>4.12.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- HttpClient 5.x - 默认依赖(推荐使用) -->
|
||||
<!-- HttpClient 5.x - 可选依赖,显式使用 HttpComponents 实现时需要 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
|
||||
@@ -32,12 +32,10 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
|
||||
@@ -8,7 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* @author <a href="https://github.com/lixize">Zeyes</a>
|
||||
*/
|
||||
@Slf4j
|
||||
public class WxChannelServiceImpl extends WxChannelServiceHttpComponentsImpl {
|
||||
public class WxChannelServiceImpl extends WxChannelServiceHttpClientImpl {
|
||||
|
||||
public WxChannelServiceImpl() {
|
||||
}
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
<artifactId>okhttp</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- HttpClient 5.x - 默认依赖(推荐使用) -->
|
||||
<!-- HttpClient 5.x - 可选依赖,显式使用 HttpComponents 实现时需要 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- HttpClient 4.x - 默认依赖(为了保持向后兼容) -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
@@ -45,7 +45,6 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
|
||||
@@ -34,12 +34,10 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
|
||||
@@ -6,6 +6,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Slf4j
|
||||
public class WxMaServiceImpl extends WxMaServiceHttpComponentsImpl {
|
||||
public class WxMaServiceImpl extends WxMaServiceHttpClientImpl {
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import me.chanjar.weixin.common.bean.WxAccessTokenEntity;
|
||||
import me.chanjar.weixin.common.error.WxError;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
|
||||
import me.chanjar.weixin.common.util.http.HttpClientType;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mockito.Mockito;
|
||||
@@ -118,6 +119,8 @@ public class WxMaServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void testGetRequestType() {
|
||||
assertThat(new WxMaServiceImpl().getRequestType()).isEqualTo(HttpClientType.APACHE_HTTP);
|
||||
assertThat(new WxMaServiceHttpComponentsImpl().getRequestType()).isEqualTo(HttpClientType.HTTP_COMPONENTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -34,12 +34,10 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
|
||||
@@ -2,11 +2,11 @@ package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 默认接口实现类,使用apache httpClient 5实现
|
||||
* 默认接口实现类,使用 Apache HttpClient 4 实现.
|
||||
* Created by Binary Wang on 2017-5-27.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public class WxMpServiceImpl extends WxMpServiceHttpComponentsImpl {
|
||||
public class WxMpServiceImpl extends WxMpServiceHttpClientImpl {
|
||||
}
|
||||
|
||||
@@ -51,12 +51,10 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
|
||||
@@ -3,6 +3,6 @@ package me.chanjar.weixin.open.api.impl;
|
||||
/**
|
||||
* @author <a href="https://github.com/007gzs">007</a>
|
||||
*/
|
||||
public class WxOpenServiceImpl extends WxOpenServiceHttpComponentsImpl {
|
||||
public class WxOpenServiceImpl extends WxOpenServiceApacheHttpClientImpl {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.github.binarywang.wxpay.service.impl;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信支付接口请求实现类,默认使用Apache HttpClient 5实现
|
||||
* 微信支付接口请求实现类,默认使用 Apache HttpClient 4 实现.
|
||||
* Created by Binary Wang on 2017-7-8.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public class WxPayServiceImpl extends WxPayServiceHttpComponentsImpl {
|
||||
public class WxPayServiceImpl extends WxPayServiceApacheHttpImpl {
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ public class BaseWxPayServiceImplTest {
|
||||
@Inject
|
||||
private WxPayService payService;
|
||||
|
||||
@Test
|
||||
public void testDefaultImplUsesApacheHttpClient() {
|
||||
assertThat(new WxPayServiceImpl()).isInstanceOf(WxPayServiceApacheHttpImpl.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#unifiedOrder(WxPayUnifiedOrderRequest)}.
|
||||
*
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
|
||||
@@ -2,11 +2,11 @@ package me.chanjar.weixin.qidian.api.impl;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 默认接口实现类,使用apache httpClient 5实现
|
||||
* 默认接口实现类,使用 Apache HttpClient 4 实现.
|
||||
* Created by Binary Wang on 2017-5-27.
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public class WxQidianServiceImpl extends WxQidianServiceHttpComponentsImpl {
|
||||
public class WxQidianServiceImpl extends WxQidianServiceHttpClientImpl {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user