读取配置信息类

springboot导出配置信息作为一个类的常见操作
@Component
@ConfigurationProperties(prefix = "aliyun.oss.file")
/* 这里去实现一个InitializingBean初始化bean的类 */
public class PropertiesUtils implements InitializingBean {
    @Override
    public void afterPropertiesSet() throws Exception {
        //在bean赋值创建好之后进行的操作
        END_POINT = endpoint;
        KEY_ID = keyid;
        KEY_SECRET = keysecret;
        BUCKET_NAME = bucketname;
    }
    private static String END_POINT;
    private static String KEY_ID;
    private static String KEY_SECRET;
    private static String BUCKET_NAME;


    private String endpoint;
    private String keyid;
    private String keysecret;
    private String bucketname;
}

通常这么创建需要导出配置信息类

posted @ 2021-07-31 00:15  Coder-Wang  阅读(62)  评论(0编辑  收藏  举报