提交 d16dda02 编写于 作者: 如梦技术's avatar 如梦技术 🐛

🔖 v1.4.0.

上级 50c3b916
......@@ -34,7 +34,11 @@ public class WeixinAppConfig implements SmartInitializingSingleton {
boolean isdev = weixinProperties.isDevMode();
ApiConfigKit.setDevMode(isdev);
ApiConfigKit.setAccessTokenCache(accessTokenCache);
WxConfigLoader configLoader = provider.getIfAvailable(() -> WxConfigLoader.DEFAULT);
WxConfigLoader configLoader = provider.getIfAvailable();
// 兼容老板 spring boot
if (configLoader == null) {
configLoader = WxConfigLoader.DEFAULT;
}
List<WxConf> wxConfList = new ArrayList<>(weixinProperties.getWxConfigs());
wxConfList.addAll(configLoader.loadWx());
for (WxConf conf : wxConfList) {
......
......@@ -14,8 +14,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.12.RELEASE</version>
<!--<version>2.0.4.RELEASE</version>-->
<!-- <version>1.5.12.RELEASE</version>-->
<version>2.2.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
......@@ -33,7 +33,7 @@
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>spring-boot-starter-weixin</artifactId>
<version>1.3.6</version>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -4,6 +4,7 @@ import com.jfinal.weixin.sdk.msg.in.InTextMsg;
import com.jfinal.weixin.sdk.msg.in.event.InFollowEvent;
import com.jfinal.weixin.sdk.msg.in.event.InMenuEvent;
import com.jfinal.weixin.sdk.msg.out.OutTextMsg;
import com.jfinal.weixin.sdk.utils.JsonUtils;
import net.dreamlu.weixin.annotation.WxMsgController;
import net.dreamlu.weixin.properties.DreamWeixinProperties;
import net.dreamlu.weixin.spring.DreamMsgControllerAdapter;
......@@ -24,7 +25,7 @@ public class WeixinController extends DreamMsgControllerAdapter {
@Override
protected void processInTextMsg(InTextMsg inTextMsg) {
System.out.println(weixinProperties.getWxaConfig().getAppId());
System.out.println(JsonUtils.toJson(weixinProperties));
OutTextMsg outMsg = new OutTextMsg(inTextMsg);
outMsg.setContent(inTextMsg.getContent());
render(outMsg);
......
package com.example.demo;
import net.dreamlu.weixin.config.WxConf;
import net.dreamlu.weixin.config.WxConfigLoader;
import net.dreamlu.weixin.config.WxaConf;
import org.springframework.context.annotation.Configuration;
import java.util.Collections;
import java.util.List;
/**
* 微信配置加载器,用于自定义实现
*
* @author L.cm
*/
@Configuration
public class WxConfigDatabaseLoader implements WxConfigLoader {
@Override
public List<WxConf> loadWx() {
WxConf wxConf = new WxConf();
wxConf.setAppId("wxc03edcd008ad1e70");
wxConf.setAppSecret("11ed9e2b8e3e3c131e7be320a42b2b5a");
wxConf.setToken("123456");
return Collections.singletonList(wxConf);
}
@Override
public List<WxaConf> loadWxa() {
return Collections.emptyList();
}
}
......@@ -3,15 +3,16 @@ dream:
dev-mode: true
url-patterns: /weixin/**
wx-configs:
- appId: wxc03edcd008ad1e70
appSecret: 11ed9e2b8e3e3c131e7be320a42b2b5a
token: 123456
# 可自定义 WxConfigLoader 用于从数据库等地方加载配置
# - appId: wxc03edcd008ad1e70
# appSecret: 11ed9e2b8e3e3c131e7be320a42b2b5a
# token: 123456
- appId: wx9803d1188fa5fbda
appSecret: db859c968763c582794e7c3d003c3d87
token: 123456
encodingAesKey: xxx
messageEncrypt: true
wxa-config:
app-id: wx4f53594f9a6b3dcb
app-secret: eec6482ba3804df05bd10895bace0579
wxa-configs:
- app-id: wx4f53594f9a6b3dcb
app-secret: eec6482ba3804df05bd10895bace0579
json-type: jackson
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册