poi导出excel报错,本地测试通过,但发布到测试以及客户环境报错。
我的本地代码,导出excel都是可以的。但是发布到了测试环境或者客户环境,就会报错。
主要报错信息如下:
(每个页面的导出报错都不相同。。然后还报了一个org.apache.poi.hssf.util.HSSFColor的错误 T 。T 嘤嘤......哭泣脸)
第一个:
org.springframework.web.util.NestedServletException:Handler dispatch failed;
nested exception is java.lang.NoClassDefFoundError: Could not initialize class java.awt.Font
第二个:
org.springframework.web.util.NestedServletException: Handler dispatch failed;
nested exception is java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
首先换了poi的版本,不好用。
然后面向百度开发!说是tomcat的bin目录下catalina.sh配置中加入一句话,
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
加入后重启~~~~ 哎 好用了鸭!^_^
原因:看这里 →→→→→ 参考博客:https://blog.csdn.net/catoop/article/details/49057291