如何强制weblogic从web-inf / lib加载类

时间:2019-04-28 10:48:29

标签: classloader weblogic12c

此问题源自问题here

基本上,我希望从战争的web-inf \ lib中加载slf4j jar,而不是从weblogic的旧版jar中加载。

注意-正在部署WAR而不是EAR文件。 在 weblogic.xml 中尝试了以下操作:

<wls:container-descriptor>
    <wls:prefer-application-resources>
        <wls:resource-name>org.slf4j.*</wls:resource-name>
        <wls:resource-name>ch.qos.*</wls:resource-name>
    </wls:prefer-application-resources>
</wls:container-descriptor>

但是,weblogic仍从其旧版jar而不是从我的应用程序的web-inf \ lib

加载这些类。

有人可以建议其他方法吗?

1 个答案:

答案 0 :(得分:0)

这些标记仅用于资源,您需要Filtering Classloader:

<wls:prefer-application-packages>
    <wls:package-name>org.slf4j</wls:package-name>
    <wls:package-name>ch.qos</wls:package-name>
</wls:prefer-application-packages>

另一种方法是使用:prefer-web-inf-classes (不能同时使用)

更多信息:https://docs.oracle.com/cd/E24329_01/web.1211/e24368/classloading.htm#WLPRG315