In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you how to use weixin-java-miniapp configuration for a single Mini Program, with detailed content and clear logic. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
In the development of Mini Program back-end interface, using the weixin-java-miniapp module in weixin-java-tools can often get twice the result with half the effort.
Introduction of weixin-java-tools
Search for weixin-java-miniapp in https://mvnrepository.com/ and enter the project WeChat Mini Programs Java SDK.
Select the appropriate official version to use.
Add the following configuration items to the dependency in maven:
Com.github.binarywang weixin-java-miniapp 3.3.0
Add the following configuration items to gradle:
Compile ("com.github.binarywang:weixin-java-miniapp:3.3.0")
Note: the above version I use is 3.3.0, which actually depends on the version you want to use.
Configuration file
There are four main configuration parameters in the configuration file, which are:
AppId
Secret
Token
AesKey
Configuration initialization:
Weixin-java-miniapp can be configured using annotations as follows:
Create the WxMaConfiguration class in the config package.
Use the @ Configuration annotation to configure Mini Program-related parameters, please refer to the following code.
The code example shows a single Mini Program configuration example. If you need to configure multiple Mini Program parameters, please refer to the official case and click to enter.
Package com.diboot.miniapp.config;import cn.binarywang.wx.miniapp.api.WxMaService;import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig;import dibo.framework.config.BaseConfig;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class WxMaConfiguration {/ / the way to get the configuration here can be changed to your own way, or you can get the configuration by annotations and so on. Private static final String appId = BaseConfig.getProperty ("wechat.appId"); private static final String secret = BaseConfig.getProperty ("wechat.secret"); private static final String token = BaseConfig.getProperty ("wechat.token"); private static final String aesKey = BaseConfig.getProperty ("wechat.aesKey"); private static WxMaService wxMaService = null; @ Bean public Object services () {WxMaInMemoryConfig config = new WxMaInMemoryConfig (); config.setAppid (appId); config.setSecret (secret); config.setToken (token); config.setAesKey (aesKey) WxMaService = new WxMaServiceImpl (); wxMaService.setWxMaConfig (config); return Boolean.TRUE;} public static WxMaService getWxMaService () {return wxMaService;}}
Start using
Where you need to use Mini Program-related APIs, you only need to obtain the wxMaService through the static method getWxMaService () in the configuration class, such as:
/ / get Mini Program service instance WxMaService wxMaService = WxMaConfiguration.getWxMaService (); / / get Mini Program QR code generation instance WxMaQrcodeService wxMaQrcodeService = wxMaService.getQrcodeService (); / / you can start to use wxMaQrcodeService for QR code related processing. These are all the contents of the article "how to use weixin-java-miniapp configuration for a single Mini Program". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.