描述:項目在tomcat服務器上部署時,使用POI導出Excel文件不會報錯,能夠正常下載,將項目部署在Weblogic服務器上后,使用POI導出Excel文件報錯:
java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setEntityExpansi
原因:在Weblogic中,如果事先未將項目自帶的依賴文件優先級設置為最高,那么Weblogic默認會先去加載其本身就有的低版本的beansxml依賴,高版本中的方法就會出現找不到的情況
解決方法:設置項目依賴文件的優先級,在項目的文件META-INF下新建一個weblogic.xml,內容如下:
<?xml version="1.0"?> <weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd"> <container-descriptor> <prefer-web-inf-classes>true</prefer-web-inf-classes> </container-descriptor> </weblogic-web-app>
重啟Weblogic即可。