java.lang.NoClassDefFoundError:org / apache / poi / ss / usermodel / ExtendedColor

时间:2015-11-03 20:10:49

标签: java excel spring apache-poi

我试图从Spring Framework中的Web应用程序导出excel文件。 首先,我是以XLS格式完成的,有效。 现在,我试图用XLSX格式做同样的事情。为此,我将一些类(如HSSFWorkbook)更改为XSSFWorkbook,或将HSSFSheet更改为XSSFSheet。

问题出现在这个来源的第三行:

    XSSFCellStyle estiloFecha = workbook.createCellStyle();
    estiloFecha.cloneStyleFrom(estiloNormal);
    estiloFecha.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat("dd/MM/yyyy hh:mm"));

错误是:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/ExtendedColor
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:859)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:754)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:399)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:354)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:185)
net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:159)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:108)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:193)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)

一些帮助?

1 个答案:

答案 0 :(得分:0)

对答案进行评论 - 您的POI罐子不匹配。 Apache POI有几个不同的jar,涵盖different project components。正如POI FAQ, these must all be from the same version中所解释的那样!不支持在版本之间混合jar,并且失败并出现错误,就像这样

快速修复 - 删除所有Apache POI jar,只添加最新版本的jar。

如果您无法确定您实际使用的罐子,use the code given in this FAQ entry通过类加载器报告使用了哪些罐子。然后,删除旧版本,这样您只能从一个版本中获得一组一致的POI jar

之后,考虑使用Apache Maven或Apache Ant或Groovy的Gradle等方法来处理构建过程和依赖关系。那些可以帮助您获得一致的设置,避免在您的类路径中随机悬挂随机不兼容的罐子时发现的问题!