1.properties文件在classpath根路径下读取方式

Properties properties = new Properties();
properties.load(BlogIndex.class.getResourceAsStream("/config.properties"));

2.properties文件在package路径下读取方式

Properties properties = new Properties();
properties.load(BlogIndex.class.getResourceAsStream("com/test/config.properties"));

特别提醒:

第一种方式的文件名称前必须加 /

相关文章:

  • 2022-12-23
  • 2021-10-20
  • 2021-07-07
  • 2021-12-24
  • 2022-03-10
  • 2022-12-23
  • 2022-01-16
  • 2021-05-19
猜你喜欢
  • 2021-06-08
  • 2022-12-23
  • 2021-03-31
  • 2021-10-20
  • 2021-11-01
相关资源
相似解决方案