mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	接入 weixin-mp-java ,编写相关示例。
This commit is contained in:
		| @@ -98,6 +98,11 @@ | |||||||
|                 <artifactId>yudao-spring-boot-starter-biz-pay</artifactId> |                 <artifactId>yudao-spring-boot-starter-biz-pay</artifactId> | ||||||
|                 <version>${revision}</version> |                 <version>${revision}</version> | ||||||
|             </dependency> |             </dependency> | ||||||
|  |             <dependency> | ||||||
|  |                 <groupId>cn.iocoder.boot</groupId> | ||||||
|  |                 <artifactId>yudao-spring-boot-starter-biz-weixin</artifactId> | ||||||
|  |                 <version>${revision}</version> | ||||||
|  |             </dependency> | ||||||
|  |  | ||||||
|             <!-- Spring 核心 --> |             <!-- Spring 核心 --> | ||||||
|             <dependency> |             <dependency> | ||||||
|   | |||||||
| @@ -28,8 +28,9 @@ | |||||||
|         <module>yudao-spring-boot-starter-biz-operatelog</module> |         <module>yudao-spring-boot-starter-biz-operatelog</module> | ||||||
|         <module>yudao-spring-boot-starter-biz-dict</module> |         <module>yudao-spring-boot-starter-biz-dict</module> | ||||||
|         <module>yudao-spring-boot-starter-biz-sms</module> |         <module>yudao-spring-boot-starter-biz-sms</module> | ||||||
|         <module>yudao-spring-boot-starter-extension</module> |  | ||||||
|         <module>yudao-spring-boot-starter-biz-pay</module> |         <module>yudao-spring-boot-starter-biz-pay</module> | ||||||
|  |         <module>yudao-spring-boot-starter-biz-weixin</module> | ||||||
|  |         <module>yudao-spring-boot-starter-extension</module> | ||||||
|     </modules> |     </modules> | ||||||
|  |  | ||||||
|     <artifactId>yudao-framework</artifactId> |     <artifactId>yudao-framework</artifactId> | ||||||
|   | |||||||
| @@ -72,4 +72,5 @@ | |||||||
|             <scope>test</scope> |             <scope>test</scope> | ||||||
|         </dependency> |         </dependency> | ||||||
|     </dependencies> |     </dependencies> | ||||||
|  |  | ||||||
| </project> | </project> | ||||||
|   | |||||||
| @@ -79,4 +79,5 @@ | |||||||
|         </dependency> |         </dependency> | ||||||
|         <!-- SMS SDK end --> |         <!-- SMS SDK end --> | ||||||
|     </dependencies> |     </dependencies> | ||||||
|  |  | ||||||
| </project> | </project> | ||||||
|   | |||||||
							
								
								
									
										43
									
								
								yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
|  |          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||||
|  |     <parent> | ||||||
|  |         <groupId>cn.iocoder.boot</groupId> | ||||||
|  |         <artifactId>yudao-framework</artifactId> | ||||||
|  |         <version>${revision}</version> | ||||||
|  |     </parent> | ||||||
|  |     <modelVersion>4.0.0</modelVersion> | ||||||
|  |     <artifactId>yudao-spring-boot-starter-biz-weixin</artifactId> | ||||||
|  |     <packaging>jar</packaging> | ||||||
|  |  | ||||||
|  |     <name>${artifactId}</name> | ||||||
|  |     <description>微信拓展 | ||||||
|  |         1. 基于 weixin-java-mp 库,对接微信公众号平台。目前主要解决微信公众号的支付场景。 | ||||||
|  |     </description> | ||||||
|  |     <url>https://github.com/YunaiV/ruoyi-vue-pro</url> | ||||||
|  |  | ||||||
|  |     <dependencies> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>cn.iocoder.boot</groupId> | ||||||
|  |             <artifactId>yudao-common</artifactId> | ||||||
|  |         </dependency> | ||||||
|  |  | ||||||
|  |         <!-- Test 测试相关 --> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>cn.iocoder.boot</groupId> | ||||||
|  |             <artifactId>yudao-spring-boot-starter-test</artifactId> | ||||||
|  |             <scope>test</scope> | ||||||
|  |         </dependency> | ||||||
|  |  | ||||||
|  |         <!-- 三方云服务相关 --> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>com.github.binarywang</groupId> | ||||||
|  | <!--            <artifactId>weixin-java-mp</artifactId>--> | ||||||
|  |             <artifactId>wx-java-mp-spring-boot-starter</artifactId> | ||||||
|  |             <version>4.1.9.B</version> | ||||||
|  |         </dependency> | ||||||
|  |         <!-- TODO 芋艿:清理 --> | ||||||
|  |     </dependencies> | ||||||
|  |  | ||||||
|  | </project> | ||||||
| @@ -0,0 +1,34 @@ | |||||||
|  | package cn.iocoder.yudao.framework.weixin; | ||||||
|  |  | ||||||
|  | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
|  | import me.chanjar.weixin.mp.api.WxMpService; | ||||||
|  | import org.junit.jupiter.api.Test; | ||||||
|  | import org.springframework.boot.autoconfigure.SpringBootApplication; | ||||||
|  | import org.springframework.boot.test.context.SpringBootTest; | ||||||
|  |  | ||||||
|  | import javax.annotation.Resource; | ||||||
|  |  | ||||||
|  | @SpringBootTest(classes = WxMpServiceTest.Application.class) | ||||||
|  | public class WxMpServiceTest { | ||||||
|  |  | ||||||
|  |     @Resource | ||||||
|  |     private WxMpService wxMpService; | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void testGetAccessToken() throws WxErrorException { | ||||||
|  |         String accessToken = wxMpService.getAccessToken(); | ||||||
|  |         System.out.println(accessToken); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void testGet() throws WxErrorException { | ||||||
|  |         String jsapiTicket = wxMpService.getJsapiTicket(); | ||||||
|  |         System.out.println(jsapiTicket); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @SpringBootApplication | ||||||
|  |     public static class Application { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,11 @@ | |||||||
|  | --- #################### 微信公众号相关配置 #################### | ||||||
|  | wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 | ||||||
|  |   mp: | ||||||
|  |     # 公众号配置(必填) | ||||||
|  |     app-id: wx041349c6f39b268b | ||||||
|  |     secret: 5abee519483bc9f8cb37ce280e814bd0 | ||||||
|  |     # 存储配置,解决 AccessToken 的跨节点的共享 | ||||||
|  | #    config-storage: | ||||||
|  | #      type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 | ||||||
|  | #      key-prefix: wx # Redis Key 的前缀 TODO 芋艿:解决下 Redis key 管理的配置 | ||||||
|  | #      http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 | ||||||
| @@ -31,6 +31,10 @@ | |||||||
|             <groupId>cn.iocoder.boot</groupId> |             <groupId>cn.iocoder.boot</groupId> | ||||||
|             <artifactId>yudao-spring-boot-starter-biz-sms</artifactId> |             <artifactId>yudao-spring-boot-starter-biz-sms</artifactId> | ||||||
|         </dependency> |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>cn.iocoder.boot</groupId> | ||||||
|  |             <artifactId>yudao-spring-boot-starter-biz-weixin</artifactId> | ||||||
|  |         </dependency> | ||||||
|  |  | ||||||
|         <!-- Web 相关 --> |         <!-- Web 相关 --> | ||||||
|         <dependency> |         <dependency> | ||||||
|   | |||||||
| @@ -121,6 +121,18 @@ logging: | |||||||
|   file: |   file: | ||||||
|     name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 |     name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 | ||||||
|  |  | ||||||
|  | --- #################### 微信公众号相关配置 #################### | ||||||
|  | wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 | ||||||
|  |   mp: | ||||||
|  |     # 公众号配置(必填) | ||||||
|  |     app-id: wx041349c6f39b268b | ||||||
|  |     secret: 5abee519483bc9f8cb37ce280e814bd0 | ||||||
|  |     # 存储配置,解决 AccessToken 的跨节点的共享 | ||||||
|  |     config-storage: | ||||||
|  |       type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 | ||||||
|  |       key-prefix: wx # Redis Key 的前缀 TODO 芋艿:解决下 Redis key 管理的配置 | ||||||
|  |       http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 | ||||||
|  |  | ||||||
| --- #################### 芋道相关配置 #################### | --- #################### 芋道相关配置 #################### | ||||||
|  |  | ||||||
| # 芋道配置项,设置当前项目所有自定义的配置 | # 芋道配置项,设置当前项目所有自定义的配置 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV