阿里巴巴easyexcel jar里面导入了一个poi jar类,但是外部有一个poi jar可能与easyexcel冲突

时间:2019-03-15 02:56:04

标签: java excel apache-poi

首先这是异常代码

java.lang.ClassNotFoundException: org.apache.poi.xssf.streaming.SXSSFWorkbook
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at com.alibaba.excel.context.GenerateContextImpl.<init>(GenerateContextImpl.java:64)
    at com.alibaba.excel.write.ExcelBuilderImpl.init(ExcelBuilderImpl.java:35)
    at com.alibaba.excel.ExcelWriter.<init>(ExcelWriter.java:50)
    at com.landray.kmss.km.archive.excel.DownloadServlet.doGet(DownloadServlet.java:81)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
    at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:79)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:143)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:177)
    at com.landray.kmss.third.pda.interfaces.ThirdPdaRedirectFilter.doFilter(ThirdPdaRedirectFilter.java:103)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:183)
    at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:183)
    at com.landray.kmss.sys.admin.threadmonitor.service.spring.SysAdminThreadMonitorFilter.doFilter(SysAdminThreadMonitorFilter.java:54)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:183)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy.doFilter(KmssProcessingFilterProxy.java:55)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at com.landray.kmss.sys.authentication.integration.CheckVerificationCodeFilter.doFilter(CheckVerificationCodeFilter.java:115)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:220)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
    at com.landray.kmss.web.filter.AcegiFilterToBeanProxy.doFilter(AcegiFilterToBeanProxy.java:37)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.landray.kmss.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:63)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)
2019-03-15 10:17:25,643 [ERROR] ==== http-8080-4: com.landray.kmss.util.KmssMessageWriter.logError(208)
    很抱歉,操作失败!,URL=http://localhost:8080/ekp/resource/jsp/jsperror.jsp?type=500

java.lang.NoClassDefFoundError: org/apache/poi/xssf/streaming/SXSSFWorkbook
    at com.alibaba.excel.context.GenerateContextImpl.<init>(GenerateContextImpl.java:64)
    at com.alibaba.excel.write.ExcelBuilderImpl.init(ExcelBuilderImpl.java:35)
    at com.alibaba.excel.ExcelWriter.<init>(ExcelWriter.java:50)
    at com.landray.kmss.km.archive.excel.DownloadServlet.doGet(DownloadServlet.java:81)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
    at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:79)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:143)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:177)
    at com.landray.kmss.third.pda.interfaces.ThirdPdaRedirectFilter.doFilter(ThirdPdaRedirectFilter.java:103)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:183)
    at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:183)
    at com.landray.kmss.sys.admin.threadmonitor.service.spring.SysAdminThreadMonitorFilter.doFilter(SysAdminThreadMonitorFilter.java:54)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy$VirtualFilterChain.doFilter(KmssProcessingFilterProxy.java:183)
    at com.landray.kmss.sys.authentication.integration.KmssProcessingFilterProxy.doFilter(KmssProcessingFilterProxy.java:55)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at com.landray.kmss.sys.authentication.integration.CheckVerificationCodeFilter.doFilter(CheckVerificationCodeFilter.java:115)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:220)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
    at com.landray.kmss.web.filter.AcegiFilterToBeanProxy.doFilter(AcegiFilterToBeanProxy.java:37)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.landray.kmss.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:63)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.xssf.streaming.SXSSFWorkbook
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 50 more

我可以使用Ctrl + Shift + T在项目中搜索org.apache.poi.xssf.streaming.SXSSFWorkbook类,但是只能看到一个类。我纯粹是用IntelliJ IDEA尝试过的,可以得到我期望的正确的东西。但是,当我将代码和jar放入我的官方工作区中时,我的jar中还有很多其他jar,我认为可能是两个jar相互冲突。 这是我的图片。

https://img.shownmmp.top/easyexcel.png
https://img.shownmmp.top/poi.png

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

尝试使用Maven或任何其他构建工具,在其中您可以轻松控制正在使用的依赖项并将其添加到生成的工件中。同样,使用Maven,您可以显式排除冲突的传递依赖项。