Skip to content

http框架的选用说明

Binary Wang edited this page Jul 3, 2017 · 9 revisions

目前cp和mp均支持多种http框架(apache-httpclient、jod-http以及okhttp)的自由选用,默认情况下使用apache httpclient;

拿MP举例子来说:

1、 如果想使用jodd-http,请在项目pom文件中如下配置:

        <dependency>
            <groupId>com.github.binarywang</groupId>
            <artifactId>weixin-java-mp</artifactId>
            <version>${weixin-java-mp.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.jodd</groupId>
            <artifactId>jodd-http</artifactId>
            <version>3.7.1</version>
        </dependency>

此时应该使用的 WxMpService实现类应该是: me.chanjar.weixin.mp.api.impl.WxMpServiceJoddHttpImpl;

2、如果想使用okhttp,请在项目pom文件中如下配置:

        <dependency>
            <groupId>com.github.binarywang</groupId>
            <artifactId>weixin-java-mp</artifactId>
            <version>${weixin-java-mp.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.7.0</version>
        </dependency>

此时应该使用的 WxMpService实现类应该是: me.chanjar.weixin.mp.api.impl.WxMpServiceOkHttpImpl;

Clone this wiki locally