docker部署验证码项目报错:at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)

 

如果docker部署启动报错

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)
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(NativeConstructorAccesso

 

再dockerfile文件里面添加

RUN apk add --update ttf-dejavu fontconfig

 如下所示

ADD app.jar app.jar
RUN apk add --update ttf-dejavu fontconfig
ENTRYPOINT ["java","-jar","/app.jar"]

 

但是上面这种方式有个问题就是很慢,所以我们可以直接使用现有的镜像

把dockerfile文件使用的基本镜像换掉

FROM frolvlad/alpine-java:jdk8-slim

 

用这个镜像就快很多了

 

posted @ 2021-08-26 13:43  yvioo  阅读(3217)  评论(0编辑  收藏  举报