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

feat: v1.2.0 消息控制器默认为多例,因为 jfinal-weixin 控制器上 inMsg 作为了全局变量。

上级 ebe4da27
......@@ -8,7 +8,7 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>spring-boot-starter-weixin</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
```
......@@ -47,7 +47,22 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
| dream.weixin.wxa-config | 小程序配置 | 小程序配置 |
`注意`
- 可参考demo中的[application.yml](spring-boot-weixin-demo/src/main/resources/application.yml)
- demo中的`application.yml`
```yml
dream:
weixin:
dev-mode: true
wx-configs:
- appId: wx9803d1188fa5fbda
appSecret: db859c968763c582794e7c3d003c3d87
- appId: wxc03edcd008ad1e70
appSecret: 11ed9e2b8e3e3c131e7be320a42b2b5a
token: 123456
wxa-config:
appid: wx4f53594f9a6b3dcb
appSecret: eec6482ba3804df05bd10895bace0579
```
- cache使用spring的cache,需要`@EnableCaching`开启。
- `access-token-cache`建议配置有效时间7100秒。
......@@ -56,13 +71,18 @@ jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户
<img src="https://gitee.com/uploads/images/2018/0311/153556_679db579_372.jpeg" width="250px"/>
## VIP群
捐助¥199即可加入如梦技术VIP,捐助后联系QQ: 596392912
捐助~~¥199~~限时¥99,即可加入如梦技术VIP,捐助后联系QQ: 596392912
#### VIP权益
1. spring boot版安全框架(maven + spring boot + spring security + thymeleaf)
2. 技术资料共享
2. 技术资料共享,技术指导和技术路线规划。
3. spring cloud脚手架(改造中)
4. 更多私有Git资源,
### spring boot版安全框架 Demo
地址:http://demo.dreamlu.net
账号vs密码:test、test
VERSION=1.1.0
VERSION=1.2.0
GROUPID=net.dreamlu
userName=chunmeng
......
package net.dreamlu.weixin.annotation;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.lang.annotation.*;
......@@ -13,6 +15,7 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public @interface WxMsgController {
String value() default "/";
......
......@@ -27,5 +27,8 @@ public class WeixinAppConfig implements InitializingBean {
WxaConfig wxaConfig = weixinProperties.getWxaConfig();
WxaConfigKit.setDevMode(isdev);
WxaConfigKit.setWxaConfig(wxaConfig);
if (WxaMsgParser.JSON == weixinProperties.getWxaMsgParser()) {
WxaConfigKit.useJsonMsgParser();
}
}
}
package net.dreamlu.weixin.config;
/**
* 小程序消息解析
*
* @author L.cm
*/
public enum WxaMsgParser {
JSON, XML
}
......@@ -4,6 +4,7 @@ import com.jfinal.weixin.sdk.api.ApiConfig;
import com.jfinal.wxaapp.WxaConfig;
import lombok.Getter;
import lombok.Setter;
import net.dreamlu.weixin.config.WxaMsgParser;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
......@@ -13,35 +14,51 @@ import java.util.List;
public class DreamWeixinProperties {
/**
* JFinal filter拦截的路由
* JFinal filter拦截的路由,默认:/weixin/*
*/
@Getter
@Setter
private String urlPatterns = "/weixin/*";
/**
* 是否开发模式
* 是否开发模式,默认:false
*/
@Getter
@Setter
private boolean devMode = false;
/**
* accessTokenCache
* Spring cache name
* Spring cache name,需要开启spring cache,默认:dreamWeixinCache
*/
@Getter
@Setter
private String accessTokenCache = "dreamWeixinCache";
/**
* 多公众号url挂参,默认:appId
*/
@Getter
@Setter
private String appIdKey = "appId";
/**
* 多公众号配置
*/
@Getter
private List<ApiConfig> wxConfigs = new ArrayList<ApiConfig>();
/**
* 小程序配置
*/
@Getter
@Setter
private WxaConfig wxaConfig = new WxaConfig();
/**
* 小程序消息解析,默认xml,支持json和xml
*/
@Getter
@Setter
private WxaMsgParser wxaMsgParser = WxaMsgParser.XML;
}
......@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<version>1.5.12.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
......@@ -36,7 +36,7 @@
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>spring-boot-starter-weixin</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -26,7 +26,7 @@ public class WeixinController extends MsgControllerAdapter {
protected void processInTextMsg(InTextMsg inTextMsg) {
System.out.println(weixinProperties.getWxaConfig().getAppId());
OutTextMsg outMsg = new OutTextMsg(inTextMsg);
outMsg.setContent("文本消息~");
outMsg.setContent(inTextMsg.getContent());
render(outMsg);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册