README.md 5.1 KB
Newer Older
如梦技术's avatar
如梦技术 已提交
1
## 说明
2 3
[![Mica Maven release](https://img.shields.io/nexus/r/https/oss.sonatype.org/net.dreamlu/mica-weixin.svg?style=flat-square)](https://mvnrepository.com/artifact/net.dreamlu/mica-weixin)

如梦技术's avatar
如梦技术 已提交
4 5
jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户使用。

6
具体demo请查看:`mica-weixin-demo`[JFinal-weixin文档](https://gitee.com/jfinal/jfinal-weixin/wikis/pages?title=Home)
如梦技术's avatar
如梦技术 已提交
7

如梦技术's avatar
如梦技术 已提交
8
## 开源推荐
9
- Spring boot 微服务,高效开发之 mica 工具集:[https://gitee.com/596392912/mica](https://gitee.com/596392912/mica)
如梦技术's avatar
如梦技术 已提交
10 11 12 13
- `Avue` 一款基于vue可配置化的神奇框架:[https://gitee.com/smallweigit/avue](https://gitee.com/smallweigit/avue)
- `pig` 宇宙最强微服务(架构师必备):[https://gitee.com/log4j/pig](https://gitee.com/log4j/pig)
- `SpringBlade` 完整的线上解决方案(企业开发必备):[https://gitee.com/smallc/SpringBlade](https://gitee.com/smallc/SpringBlade)
- `IJPay` 支付SDK让支付触手可及:[https://gitee.com/javen205/IJPay](https://gitee.com/javen205/IJPay)
如梦技术's avatar
如梦技术 已提交
14

如梦技术's avatar
如梦技术 已提交
15 16 17
## 兼容性
支持 Spring boot 1.x 和 2.x

如梦技术's avatar
如梦技术 已提交
18
## Jar包依赖(最新)
如梦技术's avatar
如梦技术 已提交
19 20 21
```xml
<dependency>
    <groupId>net.dreamlu</groupId>
22
    <artifactId>mica-weixin</artifactId>
如梦技术's avatar
如梦技术 已提交
23
    <version>2.1.0</version>
如梦技术's avatar
如梦技术 已提交
24 25 26 27 28 29
</dependency>
```

## 使用
### 消息
#### 公众号
如梦技术's avatar
v1.3.0  
如梦技术 已提交
30
1. 继承`DreamMsgControllerAdapter`,实现需要重写的消息。
如梦技术's avatar
如梦技术 已提交
31

如梦技术's avatar
v1.3.0  
如梦技术 已提交
32
2. 类添加注解`@WxMsgController`,注解value为你的消息地址,使用/weixin/wx,已经组合[@RequestMapping和@Controller]
如梦技术's avatar
如梦技术 已提交
33 34

### 小程序
如梦技术's avatar
v1.3.0  
如梦技术 已提交
35
1. 继承`DreamWxaMsgController`,实现需要重写的消息。
如梦技术's avatar
如梦技术 已提交
36

如梦技术's avatar
v1.3.0  
如梦技术 已提交
37
2. 添加注解`@WxMsgController`,注解value为你的消息地址,使用/weixin/wxa,已经组合[@RequestMapping和@Controller]
如梦技术's avatar
如梦技术 已提交
38 39

### Api
如梦技术's avatar
v1.3.0  
如梦技术 已提交
40
- 类添加`@WxApi`,注解value为你的消息地址,使用/weixin/api,已经组合[@RequestMapping和@Controller]
如梦技术's avatar
如梦技术 已提交
41

如梦技术's avatar
如梦技术 已提交
42 43 44
### access token cache
您可以配置 [mica-caffeine](https://gitee.com/596392912/mica/tree/master/mica-caffeine)[mica-redis](https://gitee.com/596392912/mica/tree/master/mica-redis) 实现 access token 的缓存。

如梦技术's avatar
如梦技术 已提交
45
### 配置
如梦技术's avatar
如梦技术 已提交
46 47
| 配置项 | 默认值 | 说明 |
| ----- | ------ | ------ |
48
| dream.weixin.access-token-cache | dreamWeixinCache#7100s | 缓存名,需要开启spring cache |
如梦技术's avatar
如梦技术 已提交
49
| dream.weixin.app-id-key | appId | 多公众号参数名,如:/weixin/wx?appId=xxx |
如梦技术's avatar
如梦技术 已提交
50
| dream.weixin.dev-mode | false | 开发模式 |
如梦技术's avatar
v1.3.0  
如梦技术 已提交
51
| dream.weixin.url-patterns | /weixin/* | weixin 消息处理spring拦截器url前缀 |
如梦技术's avatar
如梦技术 已提交
52
| dream.weixin.wx-configs | 公众号的配置 | 多公众号配置 |
如梦技术's avatar
如梦技术 已提交
53
| dream.weixin.wxa-configs | 小程序配置 | 小程序配置 |
如梦技术's avatar
如梦技术 已提交
54

如梦技术's avatar
如梦技术 已提交
55
`注意`
56 57 58 59 60 61 62 63 64 65 66
- demo中的`application.yml`
```yml
dream:
  weixin:
    dev-mode: true
    wx-configs:
      - appId: wx9803d1188fa5fbda
        appSecret: db859c968763c582794e7c3d003c3d87
      - appId: wxc03edcd008ad1e70
        appSecret: 11ed9e2b8e3e3c131e7be320a42b2b5a
        token: 123456
如梦技术's avatar
如梦技术 已提交
67 68
        encodingAesKey: xxx
        messageEncrypt: true
如梦技术's avatar
如梦技术 已提交
69 70 71
    wxa-configs:
      - app-id: wx4f53594f9a6b3dcb
        app-secret: eec6482ba3804df05bd10895bace0579
72 73
```

如梦技术's avatar
如梦技术 已提交
74 75
- `access-token-cache`建议配置有效时间7100秒。

如梦技术's avatar
v1.3.0  
如梦技术 已提交
76
## 更新说明
如梦技术's avatar
如梦技术 已提交
77 78 79 80 81
### 2021-04-27 2.1.0
- Spring cache 对象改为每次读取, caffeine 会刷新,照成引用为 null。
- 升级 jfinal-weixin 到 3.1。

### 2020-03-20 2.0.6
82 83
- 升级 jfinal-weixin 到 3.0。

如梦技术's avatar
如梦技术 已提交
84 85 86
### 2020-12-16 2.0.5
- 升级 jfinal-weixin 到 2.9,修复素材下载流被关闭的问题。

如梦技术's avatar
如梦技术 已提交
87 88 89
### 2020-12-13 2.0.4
- 调整 WxConfigLoader 方便自定义 config 存储更多属性。

如梦技术's avatar
如梦技术 已提交
90 91 92
### 2020-10-13 2.0.3
- 升级 jfinal-weixin 到 2.8

如梦技术's avatar
如梦技术 已提交
93 94 95
### 2020-09-14 2.0.2
- 升级 jfinal-weixin 到 2.7

如梦技术's avatar
如梦技术 已提交
96 97 98
### 2020-07-07 2.0.1
- 修复 java 编译版本,采用 java8。

99 100
### 2020-07-05 v2.0.0
- 改名为 mica-weixin,提升 mica 品牌。
101 102
- 内置 @EnableCaching。
- 更改缓存名为 `dreamWeixinCache#7100s`,方便和 `mica-redis` 一起使用。
103 104
- 升级 jfinal、jfinal-weixin 版本。

如梦技术's avatar
如梦技术 已提交
105 106 107 108
### 2020-05-01 v1.4.0
* 支持多小程序消息,**注意:** yml 配置 key 由 dream.weixin.wxa-config 改为 dream.weixin.wxa-configs。
* 支持自定义公众号和小程序配置加载,可用于从数据库等加载配置。
* 升级 jfinal、jfinal-weixin 版本。
如梦技术's avatar
如梦技术 已提交
109

如梦技术's avatar
如梦技术 已提交
110 111
### 2019-08-01 v1.3.6
* 升级 jfinal、jfinal-weixin、okhttp 版本。
如梦技术's avatar
如梦技术 已提交
112

如梦技术's avatar
如梦技术 已提交
113 114
### 2019-03-17 v1.3.5
* 解决单公众号下消息报错
如梦技术's avatar
如梦技术 已提交
115

如梦技术's avatar
如梦技术 已提交
116 117
### 2019-03-17 v1.3.4
* 解决小程序,启用并设置消息推送配置校验不通过的问题。
118

如梦技术's avatar
如梦技术 已提交
119 120 121 122 123 124
### 2019-03-07 v1.3.3
* 升级到 `gradle 5.2.1`
* 升级 `JFinal``3.6`
* 升级 `JFinal Weixin``2.3`
* 使用 `mica-auto` 生成 `spring.factories``devtools` 配置。
* `InMsg` 消息对象采用 `request` 存储,去掉 `@WxMsgController` 中的 Scope 配置,将消息控制器还原为单例。
如梦技术's avatar
如梦技术 已提交
125

如梦技术's avatar
如梦技术 已提交
126 127
### 2018-12-23 v1.3.2
* 修复 `SpringAccessTokenCache` 没有配置的问题,感谢 qq:`A梦的小C` 反馈。
如梦技术's avatar
如梦技术 已提交
128

如梦技术's avatar
如梦技术 已提交
129 130
### 2018-12-23 v1.3.1
* `WeixinAppConfig` 改为实现 `SmartInitializingSingleton`
如梦技术's avatar
如梦技术 已提交
131

如梦技术's avatar
如梦技术 已提交
132 133 134
### 2018-05-03 v1.3.0
* 弃用`@EnableDreamWeixin`,导入jar包即可享用。
* 将消息路由改为spring接管。
如梦技术's avatar
v1.3.0  
如梦技术 已提交
135

如梦技术's avatar
如梦技术 已提交
136 137 138 139 140
## 微信公众号

![如梦技术](docs/dreamlu-weixin.jpg)

精彩内容每日推荐!