接入 weixin-mp-java ,编写相关示例。

This commit is contained in:
YunaiV
2021-10-24 11:53:42 +08:00
parent 3a77cc239b
commit 44f357cea4
10 changed files with 113 additions and 1 deletions

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.framework.weixin;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
@SpringBootTest(classes = WxMpServiceTest.Application.class)
public class WxMpServiceTest {
@Resource
private WxMpService wxMpService;
@Test
public void testGetAccessToken() throws WxErrorException {
String accessToken = wxMpService.getAccessToken();
System.out.println(accessToken);
}
@Test
public void testGet() throws WxErrorException {
String jsapiTicket = wxMpService.getJsapiTicket();
System.out.println(jsapiTicket);
}
@SpringBootApplication
public static class Application {
}
}

View File

@ -0,0 +1,11 @@
--- #################### 微信公众号相关配置 ####################
wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
mp:
# 公众号配置(必填)
app-id: wx041349c6f39b268b
secret: 5abee519483bc9f8cb37ce280e814bd0
# 存储配置,解决 AccessToken 的跨节点的共享
# config-storage:
# type: RedisTemplate # 采用 RedisTemplate 操作 Redis会自动从 Spring 中获取
# key-prefix: wx # Redis Key 的前缀 TODO 芋艿:解决下 Redis key 管理的配置
# http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台