要取编译后的路径,而不是你看到的src/main/resources的路径。如下:

URL url = MyTest.class.getClassLoader().getResource("userFile.properties");

File file = new File(url.getFile());

或者

InputStream is = MyTest.class.getClassLoader().getResourceAsStream("userFile.properties");

链接:https://blog.csdn.net/totally123/article/details/72901076

相关文章:

  • 2021-09-19
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-08-23
  • 2022-01-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-19
  • 2022-02-11
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2021-06-11
相关资源
相似解决方案