Spring Boot PDF文件java.nio.file.nosuchfileexception
在我的春季启动应用程序中 我将mypdffile.pdf保留在资源文件夹中,并且正在使用以下代码访问和编码
字节[] encodedByte = base64.getCoder()。encode(files.readallbytes(paths.gets.gets.get(“ mypdffile.pdf”)));
它在本地工作正常,但是在GCP部署后,我的例外情况下 java.nio.file.nosuchfileException:mypdffile.pdf
可以帮助我解决这个方法。我只有在部署后才能得到这个例外。
In my spring boot application
I have kept MyPdfFile.pdf in resources folder and I am using below code to access and encode it
byte [] encodedByte = Base64.getEncoder().encode(Files.readAllBytes(Paths.get("MyPdfFile.pdf")));
Its working fine in local but after deploying in GCP I am getting below exception
java.nio.file.NoSuchFileException: MyPdfFile.pdf
Can any one help me on this How to solve. I am getting this exception only after deployment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的默认路径是 CLASSPATH,因此如果您的 pdf 位于 /user/1/2/3/4/5.pdf 并且您的 CLASSPATH 是 /user/1/2/3,请输入 /4/5.pdf
Your default path is CLASSPATH so if your pdf is at /user/1/2/3/4/5.pdf and your CLASSPATH is /user/1/2/3, type /4/5.pdf