spring-boot-starter-weixin v1.3.0 发布和使用
2018-09-08 13:18
906 查看
简介
spring-boot-starter-weixin是一个方便 Spring boot 用户快速接入
JFinal-weixin进行 微信和小程序开发的插件,支持
Spring boot 1.x和
Spring boot 2.x。
5月前发布创建了一个版本之后由于忙碌,对
1.3.0的配置bug一直没有抽时间去调试和修复,今天正式发布
v1.3.0。
具体demo请查看:spring-boot-weixin-demo 和 JFinal-weixin文档
Jar包依赖
<dependency> <groupId>net.dreamlu</groupId> <artifactId>spring-boot-starter-weixin</artifactId> <version>1.3.0</version> </dependency>
使用
消息
公众号
继承DreamMsgControllerAdapter,实现需要重写的消息。
添加注解
@WxMsgController,注解value为你的消息地址,使用/weixin/wx,已经组合[@RequestMapping和@Controller]
小程序
继承DreamWxaMsgController,实现需要重写的消息。
添加注解
@WxMsgController,注解value为你的消息地址,使用/weixin/wxa,已经组合[@RequestMapping和@Controller]
Api接口
类添加@WxApi,注解value为你的消息地址,使用/weixin/api,已经组合[@RequestMapping和@Controller]
配置
配置项 | 默认值 | 说明 |
---|---|---|
dream.weixin.access-token-cache | dreamWeixinCache | 缓存名,需要开启spring cache |
dream.weixin.app-id-key | appId | 多公众号参数名,如:/weixin/wx?appId=xxx |
dream.weixin.dev-mode | false | 开发模式 |
dream.weixin.json-type | jackson | 默认使用 jackson,可配置成jfinal,使用jfinal默认规则 |
dream.weixin.url-patterns | /weixin/* | weixin 消息处理spring拦截器url前缀 |
dream.weixin.wx-configs | 公众号的配置 | 多公众号配置 |
dream.weixin.wxa-config | 小程序配置 | 小程序配置 |
注意:
demo中的
application.yml
dream: weixin: dev-mode: true wx-configs: - appId: wx9803d1188fa5fbda appSecret: db859c968763c582794e7c3d003c3d87 - appId: wxc03edcd008ad1e70 appSecret: 11ed9e2b8e3e3c131e7be320a42b2b5a token: 123456 wxa-config: app-id: wx4f53594f9a6b3dcb app-secret: eec6482ba3804df05bd10895bace0579
cache使用spring的cache,需要
@EnableCaching开启。
access-token-cache建议配置有效时间7100秒。
相关链接
源码地址:https://gitee.com/596392912/spring-boot-starter-weixin如梦技术:https://www.dreamlu.net
相关文章推荐
- SpringBoot系列三:SpringBoot基本概念(统一父 pom 管理、SpringBoot 代码测试、启动注解分析、配置访问路径、使用内置对象、项目打包发布)
- ELK第七篇:spring-boot-starter-data-elasticsearch使用
- RabbitMQ的Java应用(3) -- 使用spring-boot-starter-amqp开发生产者应用
- SpringBoot使用MongoDB教程:spring-boot-starter-data-mongodb
- 使用spring-boot-starter-data-jpa 怎么配置使运行时输出SQL语句
- Spring Boot使用Redis进行消息的发布订阅
- spring boot开发遇到坑之spring-boot-starter-web配置文件使用教程
- 使用SwaggerSpringBootStarter展示web项目api接口
- Spring Boot使用Redis进行消息的发布订阅
- 自定义Spring Boot starter并使用EnableAutoConfiguration装配
- 使用idea创建springboot项目并打成war包发布到weblogic上
- SpringBoot整合Dubbo2.5.10,使用官方最新spring-boot-starter
- 使用spring-boot-starter-actuator,报错spring-boot-starter-actuator
- 3.玩转Spring Boot 不使用spring-boot-starter-parent构建
- spring boot maven管理--使用spring-boot-starter-parent
- Dubbo官方的Starter发布1.0.0测试版,与Spring Boot的结合将更加自然
- 使用Spring Boot发布服务和调用服务
- 使用spring-boot-starter-mail实现邮件发送
- springboot使用websocket时,打成war包,发布到服务器,项目启动报错问题
- 使用idea创建springboot项目并打成war包发布到weblogic上