首页 > 编程语言 > 详细

springBoot将配置文件读取进对象

时间:2020-06-21 10:54:11      阅读:75      评论:0      收藏:0      [点我收藏+]

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;
}

 

springBoot将配置文件读取进对象

原文:https://www.cnblogs.com/shouyaya/p/13171451.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!