Add resources or property to Websphere's class

2019-07-31 23:57发布

问题:

I've a problem and a solution. But I don't like my solution, could someone provide an elegant way of solving this?

This is for running web application inside IDE. I've an EAR project and I'm using RAD7.5. My EAR project looks like

EAR_Project
   Deployment Descriptor
     Module
     Jar1
     Jar2
      War
  Meta-Inf
    application.xml

My question is, Jar1 and Jar2 has its own libraries and properties files. As of now, I copy all libraries and properties of Jar1&Jar2 into War/Web-Inf and it works fine. Is there a config change that i make to application.xml so that I don't have to copy dependent libraries and properties? Your help is much appreciated

回答1:

In application.xml there can be <library-directory> element that points to the location to shared libraries within EAR. For example, for directory lib in the root of EAR there should be entry <library-directory>lib</library-directory> in application.xml:

<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">

  <module>
    <java>module1.jar</java>
  </module>

  <module>
    <web>
      <web-uri>module2.war</web-uri>
      <context-root>module2</context-root>
    </web>
  </module>

  <library-directory>lib</library-directory>

</application>