java WxJava integration framework to develop micro-channel public number

  1. Test account will be assigned a appId and appsecret
  2. I use this piece is NETAPP the network is mapped to the external network https://natapp.cn/

Here Insert Picture Description
4. Fill in the URL and Token, URL is a micro-channel callback address, Token custom, NetApp URL for my domain name, followed by the path of mp in WxMpPortalController, when in this submission, the callback project must start, otherwise it will fail certification

5. This development framework using micro-channel block WxJava frame
https://github.com/Wechat-Group/WxJava
6. the WxJava provide open source projects Demo
https://github.com/binarywang/weixin-java-mp-demo-springmvc
Download :
link: https: //pan.baidu.com/s/1qM6LmgL5-WuZRrMmpyVv2g
extraction code: 9ctk
7. introduction of project dependencies

<dependency>
    <groupId>com.github.binarywang</groupId>
    <artifactId>weixin-java-mp</artifactId>
    <version>3.6.0</version>
    <exclusions>
        <exclusion>
            <artifactId>xstream</artifactId>
            <groupId>com.thoughtworks.xstream</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>
        spring-cloud-starter-netflix-eureka-client
    </artifactId>
    <exclusions>
        <exclusion>
            <artifactId>xstream</artifactId>
            <groupId>com.thoughtworks.xstream</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <artifactId>xstream</artifactId>
    <groupId>com.thoughtworks.xstream</groupId>
    <version>1.4.10</version>
</dependency>

If the direct dependence

<dependency>
    <groupId>com.github.binarywang</groupId>
    <artifactId>weixin-java-mp</artifactId>
    <version>3.6.0</version>
</dependency>

There will be java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity (Lcom / thoughtworks / xstream / XStream;) V exception because version conflicts
6. configuration file, add the following configuration

wx:
  appid: ***
  appsecret: ***
  token: ***
  aeskey: ***
  1. Change WxMpConfig to obtain from a configuration file
@Configuration
public class WxMpConfig {
  @Value("${wx.token}")
  private String token;

  @Value("${wx.appid}")
  private String appid;

  @Value("${wx.appsecret}")
  private String appSecret;

  @Value("${wx.aeskey}")
  private String aesKey;

  public String getToken() {
    return this.token;
  }

  public String getAppid() {
    return this.appid;
  }

  public String getAppSecret() {
    return this.appSecret;
  }

  public String getAesKey() {
    return this.aesKey;
  }

}

The push message performs callback address to the micro-channel WxMpPortalController
such there are two methods, a get request, a post request
get request to the authentication interface to
request the interface to receive a parameter post

Test No. sweep out the two-dimensional code, sends a message, by default reply: "Reply content" has been introduced this time frame is complete

Published 11 original articles · won praise 0 · Views 339

Guess you like

Origin blog.csdn.net/dawn_li/article/details/103948534