I have application mywebapp. This application depends from myjarconfig.jar. File myjarconfig.jar contains file config.xml. To take resource I use code:
InputStream confStream = ClassLoader.class.getResourceAsStream("/conf/config.xml");
But I always receive null. When I look in debugger - I see that ClassLoader is mywebapp. Why it is not jar file? What need to check? Thanks.
如果您的jar位于WEB-INF / lib,容器的类路径,引导类路径等位置,则应使用
Thread.currentThread().getContextClassLoader().getResourceAsStream("/conf/config.xml")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.