wx-java-mp-spring-boot-starter 包
wx-java-mp-spring-boot-starter 包
介绍:
微信Java开发工具包,支持包括微信支付、开放平台、公众号、企业微信、视频号、小程序等微信功能模块的后端开发。
官网开发文档:https://gitee.com/binary/weixin-java-tools/wikis/Home
使用的样例代码:https://github.com/binarywang/wx-java-mp-demo/blob/master/README.md
包说明
包内自动保存和维持: - access_token - jsapi_ticket
pom.xml 引入包
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
<version>4.7.0</version>
</dependency>配置文件: application.properties
# 微信公众号
wx.mp.appId=appidd
wx.mp.secret=secret
wx.mp.token=token
wx.mp.aesKey=
# redis(可选)
#wx.mp.config-storage.type=RedisTemplate
#wx.mp.config-storage.key-prefix=wx
#wx.mp.config-storage.redis.host=127.0.0.1
#wx.mp.config-storage.redis.port=6379
# httpclient实现
wx.mp.config-storage.http-client-type=HttpClient
wx.mp.config-storage.http-proxy-host=
wx.mp.config-storage.http-proxy-port=
wx.mp.config-storage.http-proxy-username=
wx.mp.config-storage.http-proxy-password=使用
@RestController
@RequestMapping("/")
@SpringBootApplication
public class MpDemoApplication {
public static void main(String[] args) {
SpringApplication.run(MpDemoApplication.class, args);
}
//注入wx-java-mp-tool
@Autowired
private WxMpService mpService;
@GetMapping("/test")
public String test() throws WxErrorException {
return this.mpService.getWxMpConfigStorage().getAppId();
// 其他通能都是通过调用 this.mpService 的方法来实现
//return this.mpService.getAccessToken();
}
}