获取properties文件的内容

获取properties文件的内容

public void test() throws Exception{
        String resource = "application.properties";//resources文件夹中配置文件的路径
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(resource);
        Properties properties=new Properties();
        properties.load(inputStream);
        System.out.println(properties.getProperty("server.port"));
    }
posted @ 2020-01-03 10:27  第二人生Bonnie  阅读(169)  评论(0编辑  收藏  举报