java微信小程序中获取access_token

AccessTokenUtil .java

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class AccessTokenUtil {

    @Autowired
    private RedisTemplate redisTemplate;
    // 小程序唯一凭证,即 AppID
    public static final String appId = "xxx";
    // 小程序唯一凭证密钥,即 AppSecret
    public static final String secret = "xxx";


    /**
     * 接口调用凭证 access_token
     *
     * @return
     */
    public Str
经验分享 程序员 微信小程序 职场和发展