我想在启动应用程序时在云中更改yaml文件。 我用这段代码找出了路径。
File file = new File(
getClass().getClassLoader().getResource("project-cloud.yml").getFile()
);
log.severe("test10 " + file.toString());
输出: test10 /content/fleet.war/WEB-INF/classes/project-cloud.yml
但是当我想使用File做些事情时,例如在启动我的应用程序开始时用其他值覆盖时,他总是告诉我他没有找到文件或目录。
日志:
原因:java.io.FileNotFoundException:/content/fleet.war/WEB-INF/classes/project-cloud.yml(没有此类文件或目录)。
我在Java代码中设置了完全相同的路径,但他没有找到它。 我该怎么办?