weblogic如何强制先加载web-inf/lib下的jar

本文介绍如何通过两种方式设置WebLogic服务器优先加载WEB-INF目录下的类:一是修改WEB-INFweblogic.xml文件;二是调整startWebLogic.cmd/.sh脚本中的CLASSPATH。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

方法1:
修改WEB-INF\weblogic.xml (如果没有此文件需要先创建), 并加入下列代码: <prefer-web-inf-classes>true</prefer-web-inf-classes>
一段完整示例代码如下(WebLogic 8):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-web-app
  PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN"
  "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<weblogic-web-app>
  <container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
  </container-descriptor>
</weblogic-web-app>
方法2:
修改 startWebLogic.cmd/.sh 将这些类库置于CLASSPATH的最前端.

D:\Java\jdk-1.8\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51386,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-Dmanagement.endpoints.jmx.exposure.include=*" -javaagent:D:\Java\Idea\ideaIU-2023.2.win\plugins\java\lib\rt\debugger-agent.jar=file:/C:/Users/lenovo/AppData/Local/Temp/capture.props -Dfile.encoding=UTF-8 -classpath C:\Users\lenovo\AppData\Local\Temp\classpath857402285.jar bpa.BasServiceApplication Connected to the target VM, address: '127.0.0.1:51386', transport: 'socket' SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/Java/Maven/apache-maven-repository/org/slf4j/slf4j-nop/1.7.36/slf4j-nop-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/Java/Maven/apache-maven-repository/org/slf4j/slf4j-jdk14/1.7.36/slf4j-jdk14-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/Java/Maven/apache-maven-repository/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.helpers.NOPLoggerFactory] Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.helpers.NOPLoggerFactory loaded from file:/D:/Java/Maven/apache-maven-repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.helpers.NOPLoggerFactory at org.springframework.util.Assert.instanceCheckFailed(Assert.java:702) at org.springframework.util.Assert
最新发布
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值