Skip to content

Commit 8befed5

Browse files
author
F.Dong
authored
Merge pull request #5 from Wechat-Group/master
synchronized
2 parents 7f09902 + 87bb741 commit 8befed5

File tree

137 files changed

+4617
-2353
lines changed

Some content is hidden

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

137 files changed

+4617
-2353
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ Icon
4848
Network Trash Folder
4949
Temporary Items
5050
.apdisk
51+
/.sonar/
52+
sonar-project.properties

.travis.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
language: java
2-
jdk:
3-
- oraclejdk7
4-
5-
script: "mvn clean package -Dmaven.test.skip=true"
2+
sudo: false
3+
install: true
4+
addons:
5+
sonarqube:
6+
token:
7+
secure: "834110c7191f97ecb226970c46dcaff8e681da5a"
68

9+
jdk:
10+
- oraclejdk8
11+
#script: "mvn clean package -Dmaven.test.skip=true"
12+
13+
script:
14+
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
15+
716
branches:
817
only:
918
- develop
19+
20+
cache:
21+
directories:
22+
- '$HOME/.m2/repository'
23+
- '$HOME/.sonar/cache'
1024

1125
notifications:
1226
email:

CONTRIBUTION.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 代码贡献指南
2+
1. 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA新版本自带支持,如果没有可自行安装插件。
3+
1. 本项目可以采用两种方式接受代码贡献:
4+
* 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支,详细步骤参考后文。
5+
* 另外一种贡献代码的方式就是加入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)
6+
7+
8+
### PR方式贡献代码步骤
9+
* 在 GitHub 上 `fork` 到自己的仓库,如 `my_user/weixin-java-tools`,然后 `clone` 到本地,并设置用户信息。
10+
11+
```bash
12+
$ git clone [email protected]:my_user/weixin-java-tools.git
13+
$ cd weixin-java-tools
14+
$ git config user.name "yourname"
15+
$ git config user.email "your email"
16+
```
17+
* 修改代码后提交,并推送到自己的仓库。
18+
19+
```bash
20+
$ #do some change on the content
21+
$ git commit -am "Fix issue #1: change something"
22+
$ git push
23+
```
24+
* 在 GitHub 网站上提交 Pull Request。
25+
* 定期使用项目仓库内容更新自己仓库内容。
26+
27+
```bash
28+
$ git remote add upstream https://github.com/wechat-group/weixin-java-tools
29+
$ git fetch upstream
30+
$ git checkout develop
31+
$ git rebase upstream/develop
32+
$ git push -f origin develop
33+
```

README.md

Lines changed: 47 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,69 @@
1-
Weixin Java Tools 微信公众号/企业号开发Java SDK
2-
=====================================
1+
微信支付、公众号&企业号开发Java SDK
2+
---------------------------------
33
[![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)
5-
6-
### 注意:
7-
1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。***
8-
1. ***自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。***
9-
1. 本SDK要求的最低JDK版本是7,为满足少量还在使用JDK6的用户的需求,特意抽出独立的代码分支项目,请参考 https://github.com/binarywang/weixin-java-tools-for-jdk6 ,其他更早的JDK版本则需要自己改造实现;
10-
1. 最新更新:2016-11-30 发布2.4.0正式版!
11-
12-
===========
13-
14-
## 开发交流方式及注意事项:
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),如果无反应,可以自行搜索群号进行添加 )
4+
[![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/Wechat-Group/weixin-java-tools)
5+
6+
### 注意事项:
7+
1. 声明: ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。***
8+
1. **新手请注意,本项目仅是一个开发工具包(即SDK),未提供Web实现,建议使用maven或gradle引用本项目即可使用本SDK提供的各种功能,详情可参考下文中提到的Demo项目或本项目中的部分单元测试代码;如果没有贡献代码的意愿,不建议下载项目的源码自行编译,因为如果想看源码使用maven也是可以下载源码的**
9+
1. 最新更新:**2017-2-12 发布[【2.5.0正式版】](https://github.com/Wechat-Group/weixin-java-tools/releases)**
10+
1. 开源中国网站的本项目介绍的首页链接地址:https://www.oschina.net/p/weixin-java-tools-new
11+
1. 自2.0.0版本以来,公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。
12+
1. SDK详细开发文档请查阅 [【Wiki】](https://github.com/wechat-group/weixin-java-tools/wiki),部分文档可能未能及时更新,如有发现,可以及时上报或者自行修改。
13+
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/)
14+
1. 本SDK要求的最低JDK版本是7,还在使用JDK6的用户请参考[【此项目】]( https://github.com/binarywang/weixin-java-tools-for-jdk6) ,而其他更早的JDK版本则需要自己改造实现。
15+
1. 如有新功能需求,发现BUG,或者由于微信官方接口调整导致的代码问题,可以直接在[【Issues】](https://github.com/Wechat-Group/weixin-java-tools/issues)页提出issue,便于讨论追踪问题;
16+
1. 如果想贡献代码,请阅读[【代码贡献指南】](CONTRIBUTION.md)
17+
1. 捐助渠道已开通,如有意向请前往托管于码云的项目首页(具体地址见下文)的页面评论区上方,可以找到“捐助”按钮,非常感谢各位捐助的同学!
18+
19+
---------------------------------
20+
## SDK使用交流方式说明:
21+
1. QQ群: [![加入QQ群](https://img.shields.io/badge/QQ群-343954419-blue.svg)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15)[![加入QQ群](https://img.shields.io/badge/QQ群-343954419-blue.svg)](http://jq.qq.com/?_wv=1027&k=40lRskK),推荐点击按钮入群,当然如果无法成功操作,请自行搜索群号343954419进行添加 )
1622
1. 由于群容量有限,即将爆满,故开启付费入群模式以保证只有真实交流需求的人进入,并为保证群的活跃度,将不定期清理长时间不活跃的同学;
1723
1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入;
1824
1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB
1925
1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com
20-
1. 有功能需求或由于微信官方接口调整导致的代码问题,可以直接提出issue,便于讨论追踪问题;
21-
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/)
24-
25-
===========
2626

27+
---------------------------------
2728
## 版本说明
28-
1. 本项目定为每两个月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request;
29-
1. BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版);
29+
1. 本项目定为大约每两个月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request;
30+
1. BUG修复和新特性一般会先发布成小版本作为临时测试版本(如2.4.5.BETA,2.4.6.BETA等,即尾号不为0,并添加BETA字样,以区别于正式版);
3031
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)
3132
分别查看所有最新的版本。
3233

33-
## Maven & Gradle
34+
---------------------------------
35+
#### 本项目在几个著名的代码托管网站同步更新,地址分别是:
36+
* 码云:http://git.oschina.net/binary/weixin-java-tools
37+
* GitHub: https://github.com/wechat-group/weixin-java-tools
38+
* Bitbucket:https://bitbucket.org/binarywang/weixin-java-tools
39+
* Coding: https://git.coding.net/binarywang/weixin-java-tools.git
40+
41+
---------------------------------
42+
## 可参考的Demo项目
43+
#### 欢迎提供更多的Demo供新手参考:
44+
* https://github.com/wechat-group/weixin-java-mp-demo (公众号Demo,使用Spring MVC实现)
45+
* https://github.com/wechat-group/weixin-java-mp-multi-demo (支持多公众号)
46+
* https://github.com/wechat-group/weixin-java-tools-springmvc (公众号Demo,内含部分微信支付代码)
47+
* https://github.com/wechat-group/weixin-java-mp-demo-springboot (公众号Demo,使用Spring Boot实现)
48+
* https://github.com/wechat-group/weixin-java-cp-demo (企业号demo,筹备中)
49+
* https://github.com/wechat-group/weixin-java-pay-demo (微信支付demo,完善中) 
50+
51+
---------------------------------
52+
## Maven & Gradle 最新正式版本
3453

35-
* 公众号(订阅号、服务号):
54+
* 公众号(订阅号、服务号及微信支付):
3655

3756
maven:
3857
```xml
3958
<dependency>
4059
<groupId>com.github.binarywang</groupId>
4160
<artifactId>weixin-java-mp</artifactId>
42-
<version>2.4.0</version>
61+
<version>2.5.0</version>
4362
</dependency>
4463
```
4564
gradle:
4665
```groovy
47-
compile 'com.github.binarywang:weixin-java-mp:2.4.0'
66+
compile 'com.github.binarywang:weixin-java-mp:2.5.0'
4867
```
4968

5069
* 企业号:
@@ -54,60 +73,11 @@ maven:
5473
<dependency>
5574
<groupId>com.github.binarywang</groupId>
5675
<artifactId>weixin-java-cp</artifactId>
57-
<version>2.4.0</version>
76+
<version>2.5.0</version>
5877
</dependency>
5978
```
6079
gradle:
6180
```groovy
62-
compile 'com.github.binarywang:weixin-java-cp:2.4.0'
81+
compile 'com.github.binarywang:weixin-java-cp:2.5.0'
6382
```
6483

65-
===========
66-
67-
#### 本项目主要存放在github上,地址为 :
68-
* https://github.com/wechat-group/weixin-java-tools
69-
* ===========但同时会在其他几个网站同步更新,地址分别是:
70-
* https://bitbucket.org/binarywang/weixin-java-tools
71-
* http://git.oschina.net/binary/weixin-java-tools
72-
* https://git.coding.net/binarywang/weixin-java-tools.git
73-
74-
===========
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 (支持多公众号)
79-
1. https://github.com/wechat-group/weixin-java-tools-springmvc
80-
1. https://github.com/wechat-group/weixin-mp-demo-springboot
81-
82-
83-
===========
84-
## 关于代码贡献
85-
1. 非常欢迎和感谢对本项目发起Pull Request的同学,本项目代码风格为使用2个空格代表一个Tab,因此在提交代码时请注意一下,否则很容易在IDE格式化代码后与原代码产生大量diff,这样会给其他人阅读代码带来极大的困扰。
86-
1. 为了便于设置,本项目引入editorconfig插件,请使用eclipse的同学在贡献代码前安装相关插件,IntelliJ IDEA则自带支持,无需额外安装插件。
87-
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)
90-
91-
## PR方式贡献代码步骤
92-
* 在 GitHub 上 `fork` 到自己的仓库,如 `my_user/weixin-java-tools`,然后 `clone` 到本地,并设置用户信息。
93-
```
94-
$ git clone [email protected]: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: 1 addition & 1 deletion
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.4.0'
5+
version = '2.5.0'
66
}
77

88
subprojects {

pom.xml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0"?>
22
<project
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4-
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0">
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.github.binarywang</groupId>
77
<artifactId>weixin-java-parent</artifactId>
8-
<version>2.4.0</version>
8+
<version>2.5.0</version>
99
<packaging>pom</packaging>
1010
<name>WeiXin Java Tools - Parent</name>
1111
<description>微信公众号、企业号上级POM</description>
@@ -69,6 +69,11 @@
6969
<email>[email protected]</email>
7070
<url>https://github.com/johnnytung</url>
7171
</developer>
72+
<developer>
73+
<name>Jonk</name>
74+
<email>[email protected]</email>
75+
<url>https://github.com/aimilin6688</url>
76+
</developer>
7277
</developers>
7378

7479
<scm>
@@ -94,7 +99,6 @@
9499
<httpclient.version>4.5</httpclient.version>
95100
<slf4j.version>1.7.10</slf4j.version>
96101
<logback.version>1.1.2</logback.version>
97-
<jedis.version>2.9.0</jedis.version>
98102
<gson.version>2.7</gson.version>
99103
<guava.version>19.0</guava.version>
100104
<commons-lang3.version>3.5</commons-lang3.version>
@@ -145,12 +149,6 @@
145149
<artifactId>commons-lang3</artifactId>
146150
<version>${commons-lang3.version}</version>
147151
</dependency>
148-
<dependency>
149-
<groupId>redis.clients</groupId>
150-
<artifactId>jedis</artifactId>
151-
<version>${jedis.version}</version>
152-
<optional>true</optional>
153-
</dependency>
154152
<dependency>
155153
<groupId>com.google.guava</groupId>
156154
<artifactId>guava</artifactId>
@@ -302,7 +300,7 @@
302300
<configuration>
303301
<serverId>ossrh</serverId>
304302
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
305-
<autoReleaseAfterClose>false</autoReleaseAfterClose>
303+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
306304
</configuration>
307305
</plugin>
308306
<plugin>

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.4.0</version>
9+
<version>2.5.0</version>
1010
</parent>
1111

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

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
public class WxJsapiSignature implements Serializable {
99
private static final long serialVersionUID = -1116808193154384804L;
1010

11-
private String appid;
11+
private String appId;
1212

13-
private String noncestr;
13+
private String nonceStr;
1414

1515
private long timestamp;
1616

@@ -26,12 +26,12 @@ public void setSignature(String signature) {
2626
this.signature = signature;
2727
}
2828

29-
public String getNoncestr() {
30-
return this.noncestr;
29+
public String getNonceStr() {
30+
return nonceStr;
3131
}
3232

33-
public void setNoncestr(String noncestr) {
34-
this.noncestr = noncestr;
33+
public void setNonceStr(String nonceStr) {
34+
this.nonceStr = nonceStr;
3535
}
3636

3737
public long getTimestamp() {
@@ -50,12 +50,11 @@ public void setUrl(String url) {
5050
this.url = url;
5151
}
5252

53-
public String getAppid() {
54-
return this.appid;
53+
public String getAppId() {
54+
return appId;
5555
}
5656

57-
public void setAppid(String appid) {
58-
this.appid = appid;
57+
public void setAppId(String appId) {
58+
this.appId = appId;
5959
}
60-
6160
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import me.chanjar.weixin.common.util.ToStringUtils;
44

5+
import java.io.Serializable;
56
import java.util.ArrayList;
67
import java.util.List;
78

8-
public class WxMenuButton {
9+
public class WxMenuButton implements Serializable {
10+
private static final long serialVersionUID = -1070939403109776555L;
911

1012
private String type;
1113
private String name;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import me.chanjar.weixin.common.util.ToStringUtils;
44

5-
public class WxMenuRule {
5+
import java.io.Serializable;
6+
7+
public class WxMenuRule implements Serializable {
8+
private static final long serialVersionUID = -4587181819499286670L;
9+
610
private String tagId;
711
private String sex;
812
private String country;

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public class WxError implements Serializable {
2020
private String json;
2121

2222
public static WxError fromJson(String json) {
23-
WxError error = WxGsonBuilder.create().fromJson(json, WxError.class);
24-
return error;
23+
return WxGsonBuilder.create().fromJson(json, WxError.class);
2524
}
2625

2726
public static Builder newBuilder() {

0 commit comments

Comments
 (0)