java静态方法中读取某个配置文件中的配置

java静态方法中读取某个配置文件中的配置

注意:
application-dev.yml 配置文件名称
accout 配置文件中配置项key

    public static void main(String[] args) throws IOException {
        Properties props = new Properties();
        InputStream inputStream= ElectronicWhr.class.getClassLoader().getResourceAsStream("application-dev.yml");
        props.load(inputStream);
        String value = props.getProperty("accout");
        System.out.println("accout" + "=" + value);
    }
发布了94 篇原创文章 · 获赞 44 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/qq_43639296/article/details/103295126