1 Star 0 Fork 109

rain_2372 / spring-boot-starter-weixin

forked from 如梦技术 / mica-weixin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

说明

Mica Maven release

jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户使用。

具体demo请查看:mica-weixin-demoJFinal-weixin文档

开源推荐

兼容性

支持 Spring boot 1.x 和 2.x

Jar包依赖(最新)

<dependency>
    <groupId>net.dreamlu</groupId>
    <artifactId>mica-weixin</artifactId>
    <version>2.1.2</version>
</dependency>

使用

消息

公众号

  1. 继承DreamMsgControllerAdapter,实现需要重写的消息。

  2. 类添加注解@WxMsgController,注解value为你的消息地址,使用/weixin/wx,已经组合[@RequestMapping和@Controller]

小程序

  1. 继承DreamWxaMsgController,实现需要重写的消息。

  2. 添加注解@WxMsgController,注解value为你的消息地址,使用/weixin/wxa,已经组合[@RequestMapping和@Controller]

Api

  • 类添加@WxApi,注解value为你的消息地址,使用/weixin/api,已经组合[@RequestMapping和@Controller]

access token cache

您可以配置 mica-caffeinemica-redis 实现 access token 的缓存。

配置

配置项 默认值 说明
dream.weixin.access-token-cache dreamWeixinCache#7100s 缓存名,需要开启spring cache
dream.weixin.app-id-key appId 多公众号参数名,如:/weixin/wx?appId=xxx
dream.weixin.dev-mode false 开发模式
dream.weixin.url-patterns /weixin/* weixin 消息处理spring拦截器url前缀
dream.weixin.wx-configs 公众号的配置 多公众号配置
dream.weixin.wxa-configs 小程序配置 小程序配置

注意

  • demo中的application.yml
dream:
  weixin:
    dev-mode: true
    wx-configs:
      - appId: wx9803d1188fa5fbda
        appSecret: db859c968763c582794e7c3d003c3d87
      - appId: wxc03edcd008ad1e70
        appSecret: 11ed9e2b8e3e3c131e7be320a42b2b5a
        token: 123456
        encodingAesKey: xxx
        messageEncrypt: true
    wxa-configs:
      - app-id: wx4f53594f9a6b3dcb
        app-secret: eec6482ba3804df05bd10895bace0579
  • access-token-cache建议配置有效时间7100秒。

自定义公众号vs小程序配置

注意:实现 WxConfigLoader 即可,可以从数据库中获取。

/**
 * 微信配置加载器,用于自定义实现
 *
 * @author L.cm
 */
@Configuration
public class WxConfigDatabaseLoader implements WxConfigLoader {

	@Override
	public List<ApiConfig> loadWx() {
		// 公众号
		ApiConfig wxConf = new ApiConfig();
		wxConf.setAppId("wxc03edcd008ad1e70");
		wxConf.setAppSecret("11ed9e2b8e3e3c131e7be320a42b2b5a");
		wxConf.setToken("123456");
		return Collections.singletonList(wxConf);
	}

	@Override
	public List<WxaConfig> loadWxa() {
		// 小程序
		return Collections.emptyList();
	}
}

更新说明

2021-11-22 2.1.2

  • 微调,兼容更多版本,测试 Spring boot 2.6.0 兼容性。
  • 升级 jfinal 到 4.9.17。
  • 升级 jfinal-weixin 到 3.4,支持草稿箱和发布接口。
  • 升级 lombok 到 1.18.22。

2021-07-14 2.1.1

  • 升级 jfinal-weixin 到 3.2。

2021-04-27 2.1.0

  • Spring cache 对象改为每次读取, caffeine 会刷新,照成引用为 null。
  • 升级 jfinal-weixin 到 3.1。

2020-03-20 2.0.6

  • 升级 jfinal-weixin 到 3.0。

2020-12-16 2.0.5

  • 升级 jfinal-weixin 到 2.9,修复素材下载流被关闭的问题。

2020-12-13 2.0.4

  • 调整 WxConfigLoader 方便自定义 config 存储更多属性。

2020-10-13 2.0.3

  • 升级 jfinal-weixin 到 2.8

2020-09-14 2.0.2

  • 升级 jfinal-weixin 到 2.7

2020-07-07 2.0.1

  • 修复 java 编译版本,采用 java8。

2020-07-05 v2.0.0

  • 改名为 mica-weixin,提升 mica 品牌。
  • 内置 @EnableCaching。
  • 更改缓存名为 dreamWeixinCache#7100s,方便和 mica-redis 一起使用。
  • 升级 jfinal、jfinal-weixin 版本。

2020-05-01 v1.4.0

  • 支持多小程序消息,注意: yml 配置 key 由 dream.weixin.wxa-config 改为 dream.weixin.wxa-configs。
  • 支持自定义公众号和小程序配置加载,可用于从数据库等加载配置。
  • 升级 jfinal、jfinal-weixin 版本。

2019-08-01 v1.3.6

  • 升级 jfinal、jfinal-weixin、okhttp 版本。

2019-03-17 v1.3.5

  • 解决单公众号下消息报错

2019-03-17 v1.3.4

  • 解决小程序,启用并设置消息推送配置校验不通过的问题。

2019-03-07 v1.3.3

  • 升级到 gradle 5.2.1
  • 升级 JFinal3.6
  • 升级 JFinal Weixin2.3
  • 使用 mica-auto 生成 spring.factoriesdevtools 配置。
  • InMsg 消息对象采用 request 存储,去掉 @WxMsgController 中的 Scope 配置,将消息控制器还原为单例。

2018-12-23 v1.3.2

  • 修复 SpringAccessTokenCache 没有配置的问题,感谢 qq:A梦的小C 反馈。

2018-12-23 v1.3.1

  • WeixinAppConfig 改为实现 SmartInitializingSingleton

2018-05-03 v1.3.0

  • 弃用@EnableDreamWeixin,导入jar包即可享用。
  • 将消息路由改为spring接管。

微信公众号

如梦技术

精彩内容每日推荐!

The MIT License (MIT) Copyright (c) 2018 如梦技术 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

jfinal weixin 的 spring boot starter,这个starter是为了方便boot用户使用。 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/rain_2372/spring-boot-starter-weixin.git
git@gitee.com:rain_2372/spring-boot-starter-weixin.git
rain_2372
spring-boot-starter-weixin
spring-boot-starter-weixin
master

搜索帮助