配置类
package com.xxx.framework.xxx.common;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class WxConstants {
public static String appid;
public static String secret;
@Value("${wechat.appid}")
public void setAppid(String wxAppid) {
appid = wxAppid;
}
@Value("${wechat.secret}")
public void setSecret(String wxSecret) {
secret = wxSecret;
}
}
方法直接使用
WxConstants.appid
本文详细介绍了配置类WxConstants的实现方式,该类通过Spring框架的@Value注解从配置文件中读取微信应用的appid和secret,并提供静态字段供其他组件使用。
8276

被折叠的 条评论
为什么被折叠?



