diff --git a/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/README.md b/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/README.md index d55b442ba2..7796796bb8 100644 --- a/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/README.md +++ b/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/README.md @@ -19,12 +19,14 @@ ## 选填 wx.mp.tenantId1.token=@token wx.mp.tenantId1.aes-key=@aesKey + wx.mp.tenantId1.use-stable-access-token=@useStableAccessToken ## 应用 2 配置(必填) wx.mp.tenantId2.app-id=@appId wx.mp.tenantId2.app-secret =@secret ## 选填 wx.mp.tenantId2.token=@token wx.mp.tenantId2.aes-key=@aesKey + wx.mp.tenantId2.use-stable-access-token=@useStableAccessToken # ConfigStorage 配置(选填) ## 配置类型: memory(默认), jedis, redisson, redis_template diff --git a/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/configuration/services/AbstractWxMpConfiguration.java b/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/configuration/services/AbstractWxMpConfiguration.java index 6d37aed4fe..0fa722a611 100644 --- a/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/configuration/services/AbstractWxMpConfiguration.java +++ b/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/configuration/services/AbstractWxMpConfiguration.java @@ -115,6 +115,7 @@ private void configApp(WxMpDefaultConfigImpl config, WxMpSingleProperties corpPr String appSecret = corpProperties.getAppSecret(); String token = corpProperties.getToken(); String aesKey = corpProperties.getAesKey(); + boolean useStableAccessToken = corpProperties.isUseStableAccessToken(); config.setAppId(appId); config.setSecret(appSecret); @@ -124,6 +125,7 @@ private void configApp(WxMpDefaultConfigImpl config, WxMpSingleProperties corpPr if (StringUtils.isNotBlank(aesKey)) { config.setAesKey(aesKey); } + config.setUseStableAccessToken(useStableAccessToken); } private void configHttp(WxMpDefaultConfigImpl config, WxMpMultiProperties.ConfigStorage storage) { diff --git a/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpSingleProperties.java b/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpSingleProperties.java index 60471b1030..6302784bf0 100644 --- a/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpSingleProperties.java +++ b/spring-boot-starters/wx-java-mp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpSingleProperties.java @@ -32,4 +32,9 @@ public class WxMpSingleProperties implements Serializable { * 设置微信公众号的 EncodingAESKey. */ private String aesKey; + + /** + * 是否使用稳定版 Access Token + */ + private boolean useStableAccessToken = false; } diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md b/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md index 81a075432f..3e14f499d9 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md @@ -1,5 +1,7 @@ # wx-java-mp-spring-boot-starter + ## 快速开始 + 1. 引入依赖 ```xml @@ -11,15 +13,16 @@ 2. 添加配置(application.properties) ```properties # 公众号配置(必填) - wx.mp.appId = appId - wx.mp.secret = @secret - wx.mp.token = @token - wx.mp.aesKey = @aesKey + wx.mp.app-id=appId + wx.mp.secret=@secret + wx.mp.token=@token + wx.mp.aes-key=@aesKey + wx.mp.use-stable-access-token=@useStableAccessToken # 存储配置redis(可选) - wx.mp.config-storage.type = Jedis # 配置类型: Memory(默认), Jedis, RedisTemplate - wx.mp.config-storage.key-prefix = wx # 相关redis前缀配置: wx(默认) - wx.mp.config-storage.redis.host = 127.0.0.1 - wx.mp.config-storage.redis.port = 6379 + wx.mp.config-storage.type= edis # 配置类型: Memory(默认), Jedis, RedisTemplate + wx.mp.config-storage.key-prefix=wx # 相关redis前缀配置: wx(默认) + wx.mp.config-storage.redis.host=127.0.0.1 + wx.mp.config-storage.redis.port=6379 #单机和sentinel同时存在时,优先使用sentinel配置 #wx.mp.config-storage.redis.sentinel-ips=127.0.0.1:16379,127.0.0.1:26379 #wx.mp.config-storage.redis.sentinel-name=mymaster @@ -35,13 +38,9 @@ #wx.mp.hosts.mp-host=http://proxy.com/ ``` 3. 自动注入的类型 + - `WxMpService` - `WxMpConfigStorage` 4、参考demo: https://github.com/binarywang/wx-java-mp-demo - - - - - diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java index 912b902624..deb527e69f 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpStorageAutoConfiguration.java @@ -9,8 +9,8 @@ import me.chanjar.weixin.common.redis.JedisWxRedisOps; import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; import me.chanjar.weixin.common.redis.WxRedisOps; -import me.chanjar.weixin.mp.config.WxMpHostConfig; import me.chanjar.weixin.mp.config.WxMpConfigStorage; +import me.chanjar.weixin.mp.config.WxMpHostConfig; import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; import org.apache.commons.lang3.StringUtils; @@ -122,7 +122,7 @@ private void setWxMpInfo(WxMpDefaultConfigImpl config) { config.setSecret(properties.getSecret()); config.setToken(properties.getToken()); config.setAesKey(properties.getAesKey()); - + config.setUseStableAccessToken(wxMpProperties.isUseStableAccessToken()); config.setHttpProxyHost(configStorageProperties.getHttpProxyHost()); config.setHttpProxyUsername(configStorageProperties.getHttpProxyUsername()); config.setHttpProxyPassword(configStorageProperties.getHttpProxyPassword()); diff --git a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpProperties.java b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpProperties.java index 89d0e6629d..c4c97c4026 100644 --- a/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpProperties.java +++ b/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/properties/WxMpProperties.java @@ -40,6 +40,11 @@ public class WxMpProperties { * 设置微信公众号的EncodingAESKey. */ private String aesKey; + + /** + * 是否使用稳定版 Access Token + */ + private boolean useStableAccessToken = false; /** * 自定义host配置