JDK8线上环境导出Excel报错空指针,原因是缺少相应字体
Posted 几点雨落山前
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JDK8线上环境导出Excel报错空指针,原因是缺少相应字体相关的知识,希望对你有一定的参考价值。
java.lang.NullPointerException at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264) at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219) at sun.awt.FontConfiguration.init(FontConfiguration.java:107) at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774) at sun.font.SunFontManager$2.run(SunFontManager.java:431) at java.security.AccessController.doPrivileged(Native Method) at sun.font.SunFontManager.<init>(SunFontManager.java:376) at sun.awt.FcFontManager.<init>(FcFontManager.java:35) at sun.awt.X11FontManager.<init>(X11FontManager.java:57) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83) at java.security.AccessController.doPrivileged(Native Method) at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74) at java.awt.Font.getFont2D(Font.java:491) at java.awt.Font.canDisplayUpTo(Font.java:2060) at java.awt.font.TextLayout.singleFont(TextLayout.java:470) at java.awt.font.TextLayout.<init>(TextLayout.java:531) at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:275) at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117) at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:82) at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:658) at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:679)
安装字体:
sudo yum -y install fontconfig fc-list sudo yum install dejavu-sans-fonts fontconfig -y fc-cache fc-list
安装后重启程序;
以上是关于JDK8线上环境导出Excel报错空指针,原因是缺少相应字体的主要内容,如果未能解决你的问题,请参考以下文章
eclipse环境下的springboot框架+mybatis访问MySQL报错空指针