├── .gitignore ├── .travis.yml ├── README.md ├── commit.sh ├── pom.xml └── src └── main ├── java └── com │ └── binarywang │ └── demo │ └── wx │ └── mp │ └── MpDemoApplication.java └── resources └── application.properties /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | /.mvn/ 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - openjdk8 5 | script: "mvn clean package -DskipTests=true -Dcheckstyle.skip=true" 6 | 7 | branches: 8 | only: 9 | - develop 10 | - master 11 | 12 | cache: 13 | directories: 14 | - '$HOME/.m2/repository' 15 | 16 | notifications: 17 | email: 18 | - binarywang@vip.qq.com 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.com/binarywang/wx-java-mp-demo.svg?branch=master)](https://travis-ci.com/binarywang/wx-java-mp-demo) 2 | 3 | ### 本`Demo`使用 `Spring Boot Starter` 实现微信公众号开发功能。 4 | 5 | #### 本项目为`WxJava`的`Demo`演示程序,更多`Demo`请 [查阅此处](https://github.com/Wechat-Group/WxJava/blob/master/demo.md) 。 6 | 7 | 8 | 1. 修改对应配置为正确的配置, 9 | 2. 运行demo,执行命令 :`http get :8080/test` 10 | 11 | ``` 12 | HTTP/1.1 200 13 | Connection: keep-alive 14 | Content-Length: 5 15 | Content-Type: text/plain;charset=UTF-8 16 | Date: Fri, 04 Sep 2020 01:28:06 GMT 17 | Keep-Alive: timeout=60 18 | 19 | appId 20 | ``` 21 | -------------------------------------------------------------------------------- /commit.sh: -------------------------------------------------------------------------------- 1 | git commit -a -m ":arrow_up: 升级sdk版本为4.7.0" 2 | git pull --rebase 3 | git push origin master 4 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | com.binarywang 12 | wx-java-mp-demo 13 | 0.0.1-SNAPSHOT 14 | wx mp demo 15 | Demo project for wx mp with spring boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | com.github.binarywang 28 | wx-java-mp-spring-boot-starter 29 | 4.7.0 30 | 31 | 32 | com.github.jedis-lock 33 | jedis-lock 34 | 1.0.0 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-data-redis 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-maven-plugin 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/main/java/com/binarywang/demo/wx/mp/MpDemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.binarywang.demo.wx.mp; 2 | 3 | import me.chanjar.weixin.common.error.WxErrorException; 4 | import me.chanjar.weixin.mp.api.WxMpService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | /** 13 | * @author binary wang 14 | */ 15 | @RestController 16 | @RequestMapping("/") 17 | @SpringBootApplication 18 | public class MpDemoApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(MpDemoApplication.class, args); 22 | } 23 | 24 | @Autowired 25 | private WxMpService mpService; 26 | 27 | @GetMapping("/test") 28 | public String test() throws WxErrorException { 29 | // this.mpService.getWxMpConfigStorage().getAppId(); 30 | return this.mpService.getAccessToken(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binarywang/wx-java-mp-demo/af1b59c28547e87d85b30368c328cfddd3597fc9/src/main/resources/application.properties --------------------------------------------------------------------------------