配置文件类AppConfigTools
package com.example.tx_mini_pro.tools;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class AppConfigTools {
private static String wxAppId;
private static String wxAppSecret;
@Value("${wx.AppId}")
public void setWxAppId(String wxAppId) {
AppConfigTools.wxAppId = wxAppId;
}
@Value("${wx.AppSecret}")
public void setWxAppSecret(String wxAppSecret) {
AppConfigTools.wxAppSecret = wxAppSecret;
}
public static String getWxAppId() {
return wxAppId;
}
public static String getWxAppSecret() {
return wxAppSecret;
}
}
对应的配置文件application.properties
调用方式(任何地方)
String AppId=AppConfigTools.getWxAppId(); String AppSecret=AppConfigTools.getWxAppSecret();