linux服务器openjdk11环境easypoi导出excel报错(class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont)
1. 问题说明
1) easypoi 导出excel
2) 具体使方法:
cn.afterturn.easypoi.excel.ExcelExportUtil#exportExcel(cn.afterturn.easypoi.excel.entity.ExportParams, java.lang.Class<?>, java.util.Collection<?>)导出excel报错
3) 环境:centOS7 openjdk 11.0.5
4) 报错日志
Caused by: java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
2. 解决方案
2.1 配置yum源
2.2 安装字体
1 )yum install fontconfig
2)fc-list
查看所有字体文件及其位置
2.3 openjdk添加字体
1) cd openjdk安装目录/jre/lib
2) mkdir fonts
3) cp -r /usr/share/fonts/dejavu/. openjdk安装目录/jre/lib/fonts/
4) cd openjdk安装目录/lib
5) mkdir fonts
6) cp -r /usr/share/fonts/dejavu/. openjdk安装目录/lib/fonts/
2.4 重启服务