--When executing WAR, if there are multiple configuration files with the same name on the classpath for some reason, you want to specify the order in which they are loaded.
--Environment assumes WebSphere Liberty, Java 8
--There are three simple ways to include the configuration file and class in the classpath. I want to check these three priorities
--Include in WAR file
--Include in JAR file and place in WEB-INF / lib of WAR file
--Place outside WAR (specify in <library>
in Liberty's server.xml)
The order was as follows. Since 1 and 2 are difficult to set freely due to the packaging method and the arrangement of environment-dependent files, if you want to specify the loading order in detail, place the JAR outside the WAR, and then <library> It seems good to specify the order in detail in
.
<library>
in Liberty's server.xml)Specifically, it has such a shape. The order of specifying the child elements of <library>
is the order of class loading. When not only <file>
but also <folder>
is specified, the order of XML elements is the order of class loading.
<library id="mydir">
<file name="/mydir/foo1.jar"/>
<file name="/mydir/foo2.jar"/>
</library>
<webApplication location="/dir/bar.war">
<classloader privateLibraryRef="mydir"/>
</webApplication>
It seems that the same setting can be made by specifying Class-Path
of MANIFEST.MF, but if it is specified by Class-Path
of MANIFEST.MF included in WAR, it will not be the target of class loading for some reason. It was like.
Recommended Posts