Secondary development of open source version of wechat mall

Secondary development of open source version of wechat Mall (I)

Recently, I want to know how to connect Java with wechat platform and quickly build a complete project development. I found that there are such open source sources on the Internet. One of them is that you can open the web page to view it yourself. Here is how to connect WeChat official account and deployment.

The following is my own rapid deployment on ECs using docker .

How to connect and configure WeChat official account platform and WeChat applet?

You can apply for a test public number for rapid standardization, (WeChat official account development document), apply for test account, get appid and key.

If you pass the public network authentication and the non-public network local windows authentication, you can use the ngrok-stable-windows-amd64 software to authenticate. ngrok http 7500. Map windows ip: 7500 to the public network through reverse proxy to authenticate and connect with wechat platform. The essence of connection of wechat platform is also the connection of account password, but the connection of server. Subsequent wechat interface calls need to obtain wechat authentication token to make interface authentication calls.

Because the wechat interface is https and the ngrok http proxy is used for local call, the authentication certificate is required for SSL layer authentication and public key transmission. At this time, you can download the certificate from the wechat platform to the browser and save it locally SSL The import of security certificate is handled, the certificate is imported into the cacerts certificate Library of java, and the following official account is imported into the local java, so that when local WeChat interface is transferred, the certificate can be sent to the communication.

E:\javaDevTools\java-se-8u41-ri\bin\keytool -importcert -trustcacerts -file "E:\payLearning\wxcerts.cer" -alias ca_alias -keystore "E:\javaDevTools\java-se-8u41-ri\jre\lib\security\cacerts" -storepass changeit

The wechat applet needs to download the wechat development applet platform, compile and upload the front-end code to the applet platform and use it as a test package. Because the applet needs to connect to the https service, it means that you need to apply for the authentication certificate corresponding to the domain name. This process takes a long time, so the back-end function of applet connection has not been connected for the time being.

How to deploy on ECs?

nginx docker deployment

docker pull nginx
mkdir -p /data/nginx;
mkdir -p /data/nginx/www;
mkdir -p /data/nginx/conf;
mkdir -p /data/nginx/logs;

rm -rf /data/nginx;
rm -rf /data/nginx/www;
rm -rf /data/nginx/conf;
rm -rf //data/nginx/logs;
docker run --name nginx -p 80:80 -d nginx
#Reverse copy files after image deletion
docker cp 2053b13fb398:/etc/nginx/nginx.conf /data/nginx/;
docker cp 2053b13fb398:/etc/nginx/conf.d /data/nginx/conf/;
docker cp 2053b13fb398:/usr/share/nginx/html/ /data/nginx/www/dist;
docker cp 2053b13fb398:/var/log/nginx/ /data/nginx/logs/;
docker run --name nginx -p 80:80 -v /data/nginx/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/www/dist:/usr/share/nginx/html/ -v /data/nginx/logs/:/var/log/nginx/ -v /data/nginx/conf/conf.d:/etc/nginx/conf.d --privileged=true -d nginx

docker exec -it nginx /bin/bash

nginx configuration file

server {
    listen       80;
    listen  [::]:80;

    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        try_files $uri $uri/ /index.html;
        index index.jsp index.html index.htm;

    #The back-end reverse proxy interface address / prod API / is the front-end fixed production path 
    location /prod-api/ {
       proxy_connect_timeout 15s;
       proxy_send_timeout 15s;
       proxy_read_timeout 15s;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

java pom file plus docker deployment plug-in

        <entryPoint>["java", "-jar", "-Xms256m", "-Xmx512m", "-Xmn128m","/${}.jar"]

Later, package the front-end package into the corresponding nginx file location and start the java container to access it normally.

Later, we will describe how to implement the code and functions of the second open platform

Tags: Java Spring wechat

Posted by CNibbana on Tue, 19 Apr 2022 00:28:15 +0930