配置文件位置:

spring boot 除@Value 外,如何获得配置文件中的内容

读取文件中的内容代码:

Resource resource = new ClassPathResource("/my-application.properties");
Properties properties = PropertiesLoaderUtils.loadProperties(resource);
String name = (String) properties.get("myname"); //  myname 为my-application.properties中的键值
System.out.println("输出值。。"+ name);

相关文章:

  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-11-15
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
猜你喜欢
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 1970-01-01
  • 2021-08-16
  • 2021-06-05
相关资源
相似解决方案