I found several similar topics, like reading from inner structure etc, however it still does not solve my problem.
Project structure:
whole project -> war, which has:
several jar's connected as dependency in pom.xml;
context.xml in META-INF folder, which I need to read from one of jars.
part of it -> jar, which is dependency in war's pom.xml
I've tried a few solutions like:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream input = classLoader.getResourceAsStream("META-INF/context.xml");
However I did not expect that to work as I think my jar searches for this resource in its structure, not in war.
I need jar project to read context.xml from war project . So, jar is like inner structure and war is outer. Is that possible to do?
With getResourceAsStream() you have access to all resources in the classpath. The classpath of a webapplication consists of every jar under WEB-INF/lib and every file under WEB-INF/classes
META-INF is not in the classpath.
Please read the question: How to get resource from the context.xml file in tomcat webapp?
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.