springBoot将配置文件读取进对象

1.在配置文件,写入自定义属性

 

 2.创建相应的配置类

@Component
@ConfigurationProperties(prefix = "wechat")   //添加此注解自动将配置文件的值赋予下列属性
public class WechatAccountConfig {

    /**
     * 公众平台id
     */
    private String mpAppId;

    /**
     * 公众平台密钥
     */
    private String mpAppSecret;

    /**
     * 开放平台id
     */
    private String openAppId;

    /**
     * 开放平台密钥
     */
    private String openAppSecret;

    /**
     * 商户号
     */
    private String mchId;

    /**
     * 商户密钥
     */
    private String mchKey;

    /**
     * 商户证书路径
     */
    private String keyPath;

    /**
     * 微信支付异步通知地址
     */
    private String notifyUrl;

    /**
     * 微信模版id
     */
    private Map<String, String> templateId;
}

 

posted @ 2020-06-21 09:38  shouyaya  阅读(559)  评论(0编辑  收藏  举报