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

迷南。 2023-06-17 09:58 32阅读 0赞

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

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

  1. public static void main(String[] args) throws IOException {
  2. Properties props = new Properties();
  3. InputStream inputStream= ElectronicWhr.class.getClassLoader().getResourceAsStream("application-dev.yml");
  4. props.load(inputStream);
  5. String value = props.getProperty("accout");
  6. System.out.println("accout" + "=" + value);
  7. }

发表评论

表情:
评论列表 (有 0 条评论,32人围观)

还没有评论,来说两句吧...

相关阅读