【发布时间】:2019-10-24 00:30:26
【问题描述】:
我收到错误“java.io.FileNotFoundException:AuthKey_7RHM5B8NS7.p8(没有这样的文件或目录)”,该文件显然在我的目录中,并且我正在使用该文件的相对路径。这是我的项目目录。
项目目录图片
final ApnsClient apnsClient = new ApnsClientBuilder()
.setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST)
.setSigningKey(ApnsSigningKey.loadFromPkcs8File(new File("AuthKey_7RHM5B8NS7.p8"),
"GL87ZNESF6", "7RHM5B8NS7"))
.build();
【问题讨论】:
-
应用程序资源在部署时将成为嵌入式资源,因此明智的做法是立即开始访问它们。 embedded-resource 必须通过 URL 而不是文件访问。请参阅info. page for embedded resource 了解如何形成 URL。
-
使用:文件 f = new File(getClass().getClassLoader().getResource("filename").getFile());
标签: java maven servlets intellij-idea filenotfoundexception