获取application.yml中的值

2019-08-21 14:14:00
admin
原创
110
摘要:获取application.yml中的值
mport java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * Author:zhansan
 * Date:2019/8/21
 * Description:
 */
public class PropsUtil {
    private static Properties props = new Properties();
    private static InputStream isp = PropsUtil.class.getClassLoader().getResourceAsStream("application.yml");

    public static String get(String arg) {
        try {
            props.load(new InputStreamReader(isp, "utf-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        String result = props.getProperty(arg);
        return result;
    }
    public static String get(String arg, String arg2) {
        try {
            props.load(new InputStreamReader(isp, "utf-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        String result = props.getProperty(arg) + props.getProperty(arg2);
        return result;
    }
    public static String getNoE(String arg) {
        try {
            props.load(new InputStreamReader(isp, "utf-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        String result = props.getProperty(arg);
        return result;
    }

}
发表评论
评论通过审核之后才会显示。
文章分类
联系方式
联系人: 郑州-小万
电话: 13803993919
Email: 1027060531@qq.com
QQ: 1027060531
网址: www.wanhejia.com