如何在Wildfly中获取pdf资源文件

问题描述 投票:0回答:1

我已将资源文件保存在作为共享模块的主jar的资源文件夹下。我正在尝试使用

访问文件

File pdf1File = new File (getClass().getClassLoader().getResource("com/org/pack/Page2_Template.pdf").getFile());

我也尝试过resourceAsStream()

这是错误:

... 3 more
Caused by: java.io.FileNotFoundException: C:\wildfly\content\my-ear.ear\lib\my-jar-6.8.0.0.11-RELEASE-SNAPSHOT.jar\com\org\pack1\Page1_Template.pdf (The system cannot find the path specified)
resources wildfly classpath
1个回答
0
投票

您是否打开了jar文件,确认pdf实际上在jar中?您可以尝试使用/

开始路径
© www.soinside.com 2019 - 2024. All rights reserved.