简体   繁体   中英

How the external xml configuration files can be made available for war/ear file during run time or in class path in Websphere?

We are using Websphere 9 application server . We want some of the configuration files such as xml and properties files in a separate directory of Websphere server and want them too see accessible by ear/war file during the run time. I heard about shared libraries approach, but it apppears that only class and jar files can be used as shared libraries, but not xml and other files. Can anyone tell me an alternative solution where the external xml configuration files be made available for war/ear file during run time or in class path?

If you add a directory as a shared library path, the directory itself will be added as a class path entry to any class loader referencing the shared library (along with any jar/zip files within it), so you'll have access to loose files such as XML files through the getResource() API.

Note that the argument to getResource() needs to be relative to the location within the directory. For example, if you have the file test.xml, you could add it to the directory /sharedlib, created a shared library named "library1", and associate it with your EAR or WAR, and then your application could use use this to get at the file:

this.class.getResource("test.xml");

That would return you a URL pointing at /sharedlib/test.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM