java.lang.NullPointerException: null 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)
相關issue: https://github.com/docker-library/openjdk/issues/73`java
根據提示得出使用的jdk缺乏字體, 因此在生成圖表時獲取不到font致使NPEgit
修改Dockerfile:github
#FROM openjdk:8-jdk-alpine # openjdk:8-jdk-alpine with font support # https://hub.docker.com/r/dquintela/openjdk-8-jdk-alpine/dockerfile FROM dquintela/openjdk-8-jdk-alpine COPY apps/app.jar app.jar COPY run.sh run.sh ENTRYPOINT sh run.sh && tail -f /dev/null
從新構建鏡像便可docker
private void download(HttpServletResponse response, String fileName, List<List<String>> data) throws IOException { response.reset(); // 數據流傳輸 response.setContentType("application/octet-stream"); // 中文文件名編碼 response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8")); Sheet sheet = new Sheet(1); // 去除首行空白(默認從0開始的話, 第一行會空出給head, 但咱們在data中加入了head) sheet.setStartRow(-1); EasyExcelFactory.getWriter(response.getOutputStream()).write0(data, sheet).finish(); }