wx-java-mp-spring-boot-starter 包
- 介绍:
- 包说明
- 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();
}
}