读取配置工具类ResourceUtil

package com.alibaba.otter.canal.utils;

import com.alibaba.otter.canal.constants.ModuleEnum;
import com.alibaba.otter.canal.custom.CanalLogUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

/**
 * @author kaikai_zheng
 * @version 1.0.0
 * @className ResourceUtil
 * @description //读取application.properties
 * @data 2020-07-23 10:07
 */
@Slf4j
public class ResourceUtil {

    private static final String CONFIG = "application.properties";

    public static Properties getResource() {
        Properties props = new Properties();
        try {
            props = PropertiesLoaderUtils.loadAllProperties(CONFIG);
            CanalLogUtil.info(ModuleEnum.CANAL_CLIENT.getCode(),"load application properties success,properties="+props.toString());
        } catch (IOException e) {
            CanalLogUtil.error(ModuleEnum.CANAL_CLIENT.getCode(),"load application properties fail,err=",e);
        }
        return props;
    }

}

 

posted @ 2020-07-31 15:03  骑着蜗牛看海呀  阅读(1010)  评论(0编辑  收藏  举报