相对路径时注意:是相对项目(即包下)还是相对当前类(一般都是相对当前项目)(对于非class的资源文件eclipse编译时会直接放到bin目录下)

1.一般是从目录中加载:需要指明路径

加载.properties方式

2.另外就是通过加载器加载:配置只要是项目目录下就可以

加载.properties方式

3.spring提供加载方式(org.springframework.core.io.ClassPathResource.ClassPathResource(String path))

systemProps = new Properties();
systemProps.load(new ClassPathResource("system.properties").getInputStream());

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-07-08
  • 2021-08-08
  • 2022-02-22
猜你喜欢
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
相关资源
相似解决方案