Quick Start - Hippoom/wechat-mp-starter GitHub Wiki

Firstly, please make sure the starter is on the classpath, you can get it from Maven Central Repository:

  • Gradle
   compile 'com.github.hippoom:wechat-mp-starter:${version}'
  • Maven
   <dependency>
      <groupId>com.github.hippoom</groupId>
      <artifactId>wechat-mp-starter</artifactId>
      <version>0.1.0</version>
   </dependency>

Now you can annotate your @SpringBootApplication with @EnableWeChatMpApplication. The starter will handle the rest for you. Now you can autowire a pre-configured WxMpService in your components:

    import com.github.hippoom.wechat.mp.autoconfigure.annotation.EnableWeChatMpApplication;
    import me.chanjar.weixin.mp.api.WxMpUserService;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @EnableWeChatMpApplication
    @SpringBootApplication
    public class Application {
      
        @Autowired
        private WxMpService wxMpService
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }

You can setup your WeChat MP appId and secret in the application{-profile}.properties or application{-profile}.yaml

    wechat:
      mp:
        appId: your-app-id
        appSecret: your-app-secret
⚠️ **GitHub.com Fallback** ⚠️