Skip to content

Commit 8a2e322

Browse files
authored
Merge pull request binarywang#6 from wechat-group/develop
Develop
2 parents 2472b7b + 33ef6eb commit 8a2e322

File tree

179 files changed

+2354
-2220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+2354
-2220
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ test-config.xml
2626
/gradle/
2727
*.bat
2828
/gradlew
29+
**/build/
2930

3031
# OSX
3132
# Icon must end with two \r

README.md

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
# Weixin Java Tools 微信公众号/企业号开发Java SDK
2-
## ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools) [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK)
3-
1+
Weixin Java Tools 微信公众号/企业号开发Java SDK
2+
=====================================
3+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent)
4+
[![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools)
45

56
### 注意:
67
1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。***
78
1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。***
89
1. 本SDK要求的最低JDK版本是7,为满足少量还在使用JDK6的用户的需求,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk6 ,其他更早的JDK版本则需要自己改造实现;
9-
1. 最新更新:2016-09-30 发布2.2.0正式版!
10+
1. 最新更新:2016-10-31 发布2.3.0正式版!
1011

1112
===========
1213

1314
## 开发交流方式及注意事项:
14-
1. QQ群:343954419(因群人数限制即将爆满,故开启付费加群方式并不定期清理不活跃人群,感谢理解) [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK)
15+
1. QQ群:343954419(推荐点击按钮入群: [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15)[![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK),如果无反应,可以自行搜索群号进行添加 )
16+
1. 由于群容量有限即将爆满,现开启付费入群模式,并不定期清理长时间不活跃人士;
1517
1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入;
1618
1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB
1719
1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com
1820
1. 有功能需求或由于微信官方接口调整导致的代码问题,可以直接提出issue,便于讨论追踪问题;
1921
1. 详细开发文档请看 [Wiki](https://github.com/wechat-group/weixin-java-tools/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。
22+
1. 微信公众号官方文档入口地址:http://mp.weixin.qq.com/wiki (注意,从网上搜到的文档有的虽然地址前面跟这个一样,但明显左侧菜单不一致,是旧的文档,注意不要看错文档)。
23+
1. 各个模块的Javadoc可以在线查看:[weixin-java-mp](https://binarywang.github.io/weixin-java-mp-javadoc/)[weixin-java-common](https://binarywang.github.io/weixin-java-common-javadoc/)[weixin-java-cp](https://binarywang.github.io/weixin-java-cp-javadoc/)
2024

2125
===========
2226

2327
## 版本说明
2428
1. 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request;
2529
1. BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版);
26-
1. 目前最新版本号为 ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22)[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)
30+
1. 目前最新版本号为 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22)[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)
2731
分别查看所有最新的版本。
2832

2933
## Maven & Gradle
@@ -35,12 +39,12 @@ maven:
3539
<dependency>
3640
<groupId>com.github.binarywang</groupId>
3741
<artifactId>weixin-java-mp</artifactId>
38-
<version>2.2.0</version>
42+
<version>2.3.0</version>
3943
</dependency>
4044
```
4145
gradle:
4246
```groovy
43-
compile 'com.github.binarywang:weixin-java-mp:2.2.0'
47+
compile 'com.github.binarywang:weixin-java-mp:2.3.0'
4448
```
4549

4650
* 企业号:
@@ -50,12 +54,12 @@ maven:
5054
<dependency>
5155
<groupId>com.github.binarywang</groupId>
5256
<artifactId>weixin-java-cp</artifactId>
53-
<version>2.2.0</version>
57+
<version>2.3.0</version>
5458
</dependency>
5559
```
5660
gradle:
5761
```groovy
58-
compile 'com.github.binarywang:weixin-java-cp:2.2.0'
62+
compile 'com.github.binarywang:weixin-java-cp:2.3.0'
5963
```
6064

6165
===========
@@ -68,15 +72,42 @@ compile 'com.github.binarywang:weixin-java-cp:2.2.0'
6872
* https://git.coding.net/binarywang/weixin-java-tools.git
6973

7074
===========
71-
## 目前可参考的Demo项目有两个(目前都是公众号的,风格不同,欢迎提供更多的demo供新手参考):
72-
1. https://github.com/wechat-group/weixin-mp-demo
75+
## 可参考的Demo项目
76+
#### 目前都是公众号的,风格不同,欢迎提供更多的demo供新手参考:
77+
1. https://github.com/wechat-group/weixin-mp-demo
78+
1. https://github.com/wechat-group/weixin-mp-multi-demo (支持多公众号)
7379
1. https://github.com/wechat-group/weixin-java-tools-springmvc
80+
1. https://github.com/wechat-group/weixin-mp-demo-springboot
81+
7482

7583
===========
7684
## 关于代码贡献
7785
1. 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。
7886
1. 为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA则自带支持,无需额外安装插件。
7987
1. 本项目可以采用两种方式接受代码贡献:
88+
* 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支,详细步骤参考后文。
89+
* 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询QQ群管理员[![点击这里给我发消息](http://wpa.qq.com/pa?p=2:1211415707:51)](http://wpa.qq.com/msgrd?v=3&uin=1211415707&site=qq&menu=yes)
8090

81-
1. 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。
82-
1. 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。
91+
## PR方式贡献代码步骤
92+
* 在 GitHub 上 `fork` 到自己的仓库,如 `my_user/weixin-java-tools`,然后 `clone` 到本地,并设置用户信息。
93+
```
94+
$ git clone git@github.com:my_user/weixin-java-tools.git
95+
$ cd weixin-java-tools
96+
$ git config user.name "yourname"
97+
$ git config user.email "your email"
98+
```
99+
* 修改代码后提交,并推送到自己的仓库。
100+
```
101+
$ #do some change on the content
102+
$ git commit -am "Fix issue #1: change something"
103+
$ git push
104+
```
105+
* 在 GitHub 网站上提交 Pull Request。
106+
* 定期使用项目仓库内容更新自己仓库内容。
107+
```
108+
$ git remote add upstream https://github.com/wechat-group/weixin-java-tools
109+
$ git fetch upstream
110+
$ git checkout develop
111+
$ git rebase upstream/develop
112+
$ git push -f origin develop
113+
```

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ allprojects {
22
apply plugin: 'maven'
33

44
group = 'com.github.binarywang'
5-
version = '2.2.0'
5+
version = '2.4.0-SNAPSHOT'
66
}
77

88
subprojects {
@@ -21,7 +21,7 @@ subprojects {
2121
dependencies {
2222
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.10'
2323
compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5'
24-
compile group: 'org.jodd', name: 'jodd-http', version:'3.6.7'
24+
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.5'
2525
compile group: 'com.google.code.gson', name: 'gson', version:'2.7'
2626
compile group: 'com.google.guava', name: 'guava', version:'19.0'
2727
compile group: 'commons-codec', name: 'commons-codec', version:'1.10'

pom.xml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.github.binarywang</groupId>
77
<artifactId>weixin-java-parent</artifactId>
8-
<version>2.3.0-SNAPSHOT</version>
8+
<version>2.4.0-SNAPSHOT</version>
99
<packaging>pom</packaging>
1010
<name>WeiXin Java Tools - Parent</name>
1111
<description>微信公众号、企业号上级POM</description>
@@ -34,6 +34,36 @@
3434
<email>gaigeshen@qq.com</email>
3535
<url>https://github.com/gaigeshen</url>
3636
</developer>
37+
<developer>
38+
<name>Liu Mingbo</name>
39+
<email>liumingbo2008@gmail.com</email>
40+
<url>https://github.com/FirenzesEagle</url>
41+
</developer>
42+
<developer>
43+
<name>kakotor</name>
44+
<email>kakotor@gmail.com</email>
45+
<url>https://github.com/kakotor</url>
46+
</developer>
47+
<developer>
48+
<name>xiong</name>
49+
<email>zhaoxiong.tan@gmail.com</email>
50+
<url>https://github.com/ZhaoxiongTan</url>
51+
</developer>
52+
<developer>
53+
<name>LiuJunGuang</name>
54+
<email>aimilin@yeah.net</email>
55+
<url>https://github.com/aimilin6688</url>
56+
</developer>
57+
<developer>
58+
<name>Eric.Tsai</name>
59+
<email>xiaodong.cai.ks@gmail.com</email>
60+
<url>https://github.com/iwareserictsai</url>
61+
</developer>
62+
<developer>
63+
<name>withinthefog</name>
64+
<email>withinthefog@gmail.com</email>
65+
<url>https://github.com/withinthefog</url>
66+
</developer>
3767
</developers>
3868

3969
<scm>
@@ -50,21 +80,22 @@
5080
</modules>
5181

5282
<properties>
83+
<maven.compiler.source>1.7</maven.compiler.source>
84+
<maven.compiler.target>1.7</maven.compiler.target>
85+
5386
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5487
<downloadJavadocs>true</downloadJavadocs>
5588
<downloadSources>true</downloadSources>
5689
<httpclient.version>4.5</httpclient.version>
5790
<slf4j.version>1.7.10</slf4j.version>
5891
<logback.version>1.1.2</logback.version>
59-
<jodd-http.version>3.6.7</jodd-http.version>
6092
<jedis.version>2.9.0</jedis.version>
6193
<gson.version>2.7</gson.version>
6294
<guava.version>19.0</guava.version>
6395
<commons-lang3.version>3.5</commons-lang3.version>
6496
<commons-io.version>2.5</commons-io.version>
6597
<commons-codec.version>1.10</commons-codec.version>
66-
<jetty.version>9.3.0.M0</jetty.version>
67-
<jetty-new.version>9.3.10.v20160621</jetty-new.version>
98+
<jetty.version>9.3.0.RC0</jetty.version>
6899
</properties>
69100

70101
<dependencies>
@@ -81,13 +112,13 @@
81112
</dependency>
82113
<dependency>
83114
<groupId>org.apache.httpcomponents</groupId>
84-
<artifactId>httpmime</artifactId>
115+
<artifactId>httpclient</artifactId>
85116
<version>${httpclient.version}</version>
86117
</dependency>
87118
<dependency>
88-
<groupId>org.jodd</groupId>
89-
<artifactId>jodd-http</artifactId>
90-
<version>${jodd-http.version}</version>
119+
<groupId>org.apache.httpcomponents</groupId>
120+
<artifactId>httpmime</artifactId>
121+
<version>${httpclient.version}</version>
91122
</dependency>
92123
<dependency>
93124
<groupId>com.google.code.gson</groupId>
@@ -283,10 +314,8 @@
283314
<plugin>
284315
<groupId>org.apache.maven.plugins</groupId>
285316
<artifactId>maven-compiler-plugin</artifactId>
286-
<version>2.3.2</version>
317+
<version>3.6.0</version>
287318
<configuration>
288-
<source>1.7</source>
289-
<target>1.7</target>
290319
<encoding>UTF-8</encoding>
291320
</configuration>
292321
</plugin>

weixin-java-common/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies {
66
testCompile group: 'org.testng', name: 'testng', version:'6.8.7'
77
testCompile group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
88
testCompile group: 'com.google.inject', name: 'guice', version:'3.0'
9-
testCompile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.3.0.M0'
10-
testCompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.3.0.M0'
9+
testCompile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.3.0.RC0'
10+
testCompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.3.0.RC0'
1111
}
1212
test.useTestNG()

weixin-java-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>weixin-java-parent</artifactId>
9-
<version>2.3.0-SNAPSHOT</version>
9+
<version>2.4.0-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>weixin-java-common</artifactId>

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxCardApiSignature.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package me.chanjar.weixin.common.bean;
22

3-
import java.io.Serializable;
3+
import me.chanjar.weixin.common.util.ToStringUtils;
44

5-
import org.apache.commons.lang3.builder.ToStringBuilder;
6-
import org.apache.commons.lang3.builder.ToStringStyle;
5+
import java.io.Serializable;
76

87
/**
98
* 卡券Api签名
@@ -35,7 +34,7 @@ public class WxCardApiSignature implements Serializable {
3534

3635
@Override
3736
public String toString() {
38-
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
37+
return ToStringUtils.toSimpleString(this);
3938
}
4039

4140
public String getAppId() {

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuButton.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package me.chanjar.weixin.common.bean.menu;
22

3+
import me.chanjar.weixin.common.util.ToStringUtils;
4+
35
import java.util.ArrayList;
46
import java.util.List;
57

6-
import org.apache.commons.lang3.builder.ToStringBuilder;
7-
import org.apache.commons.lang3.builder.ToStringStyle;
8-
98
public class WxMenuButton {
109

1110
private String type;
@@ -18,10 +17,9 @@ public class WxMenuButton {
1817

1918
@Override
2019
public String toString() {
21-
return ToStringBuilder.reflectionToString(this,
22-
ToStringStyle.MULTI_LINE_STYLE);
20+
return ToStringUtils.toSimpleString(this);
2321
}
24-
22+
2523
public String getType() {
2624
return this.type;
2725
}
@@ -69,4 +67,4 @@ public String getMediaId() {
6967
public void setMediaId(String mediaId) {
7068
this.mediaId = mediaId;
7169
}
72-
}
70+
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenuRule.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.chanjar.weixin.common.bean.menu;
22

3-
import org.apache.commons.lang3.builder.ToStringBuilder;
4-
import org.apache.commons.lang3.builder.ToStringStyle;
3+
import me.chanjar.weixin.common.util.ToStringUtils;
54

65
public class WxMenuRule {
76
private String tagId;
@@ -70,6 +69,6 @@ public void setLanguage(String language) {
7069

7170
@Override
7271
public String toString() {
73-
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
72+
return ToStringUtils.toSimpleString(this);
7473
}
75-
}
74+
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/BeanUtils.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import me.chanjar.weixin.common.exception.WxErrorException;
99

1010
import java.lang.reflect.Field;
11+
import java.util.ArrayList;
12+
import java.util.Arrays;
1113
import java.util.List;
1214
import java.util.Map;
1315

@@ -28,7 +30,9 @@ public class BeanUtils {
2830
public static void checkRequiredFields(Object bean) throws WxErrorException {
2931
List<String> nullFields = Lists.newArrayList();
3032

31-
for (Field field : bean.getClass().getDeclaredFields()) {
33+
List<Field> fields = new ArrayList<>( Arrays.asList(bean.getClass().getDeclaredFields()));
34+
fields.addAll(Arrays.asList(bean.getClass().getSuperclass().getDeclaredFields()));
35+
for (Field field : fields) {
3236
try {
3337
boolean isAccessible = field.isAccessible();
3438
field.setAccessible(true);
@@ -55,7 +59,9 @@ public static void checkRequiredFields(Object bean) throws WxErrorException {
5559
*/
5660
public static Map<String, String> xmlBean2Map(Object bean) {
5761
Map<String, String> result = Maps.newHashMap();
58-
for (Field field : bean.getClass().getDeclaredFields()) {
62+
List<Field> fields = new ArrayList<>( Arrays.asList(bean.getClass().getDeclaredFields()));
63+
fields.addAll(Arrays.asList(bean.getClass().getSuperclass().getDeclaredFields()));
64+
for (Field field : fields) {
5965
try {
6066
boolean isAccessible = field.isAccessible();
6167
field.setAccessible(true);

0 commit comments

Comments
 (0)