微信公众平台新建一个测试号
springboot项目引入架包
<dependency>
<groupId>org.weixin4j.spring.boot</groupId>
<artifactId>weixin4j-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
新建controller
@RestController
@RequestMapping("/message")
public class MessageController extends WeixinJieruController {
}
新建weixin4j配置文件(一定要新建)
需要修改的地方:token、appid、secret
对应测试号的数据
weixin4j.debug=true
#微信配置接口的token(自定义的)
weixin4j.token=fly2me
#微信账号
weixin4j.oauth.originalid=gh_f0fc9fb10453
#测试号信息的appid
weixin4j.oauth.appid=wx97fc8d58401aed79
#测试号信息的appsecret
weixin4j.oauth.secret=9ddf27384483a9afd99e3cd21de23ecf
#解码模式 0明码(默认) 1标准 2加密
weixin4j.oauth.encodingtype=0
#加密模式
weixin4j.oauth.encodingaeskey=0123456789abcedfghijklmnopqrstuvwxyzZXCVBNM
weixin4j.oauth.url=
#微信域名
weixin4j.api.domain=api.weixin.qq.com
#微信支付
weixin4j.pay.partner.id=
weixin4j.pay.partner.key=
weixin4j.pay.notify_url=
weixin4j.http.connectionTimeout=25000
weixin4j.http.readTimeout=25000
weixin4j.http.cert.path=
weixin4j.http.cert.secret=
weixin4j.handler=org.weixin4j.spi.DefaultMessageHandler
测试号url需要域名可以做内网穿透,我使用的是natapp,url填入controller的访问地址,点击提交提示成功即可