Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mica
mica-weixin
提交
d16dda02
M
mica-weixin
项目概览
mica
/
mica-weixin
通知
8
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mica-weixin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d16dda02
编写于
5月 01, 2020
作者:
如梦技术
🐛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔖
v1.4.0.
上级
50c3b916
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
11 deletion
+49
-11
spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WeixinAppConfig.java
.../main/java/net/dreamlu/weixin/config/WeixinAppConfig.java
+5
-1
spring-boot-weixin-demo/pom.xml
spring-boot-weixin-demo/pom.xml
+3
-3
spring-boot-weixin-demo/src/main/java/com/example/demo/WeixinController.java
...demo/src/main/java/com/example/demo/WeixinController.java
+2
-1
spring-boot-weixin-demo/src/main/java/com/example/demo/WxConfigDatabaseLoader.java
...rc/main/java/com/example/demo/WxConfigDatabaseLoader.java
+32
-0
spring-boot-weixin-demo/src/main/resources/application.yml
spring-boot-weixin-demo/src/main/resources/application.yml
+7
-6
未找到文件。
spring-boot-starter-weixin/src/main/java/net/dreamlu/weixin/config/WeixinAppConfig.java
浏览文件 @
d16dda02
...
...
@@ -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
)
{
...
...
spring-boot-weixin-demo/pom.xml
浏览文件 @
d16dda02
...
...
@@ -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>
...
...
spring-boot-weixin-demo/src/main/java/com/example/demo/WeixinController.java
浏览文件 @
d16dda02
...
...
@@ -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
);
...
...
spring-boot-weixin-demo/src/main/java/com/example/demo/WxConfigDatabaseLoader.java
0 → 100644
浏览文件 @
d16dda02
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
();
}
}
spring-boot-weixin-demo/src/main/resources/application.yml
浏览文件 @
d16dda02
...
...
@@ -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-config
s
:
-
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录