OpenJDK:8-jdk-alpine验证码无法显示
java.lang.NullPointerException at sun.awt.FontConfiguration.getVersion
报错如下:
linux服务器
yum install fontconfig fc-cache --force
dockerfile容器操作
#软件源修改为国内镜像站 RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories #修改时区为国内 RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone && apk del tzdata # 增加字体,解决验证码、图片处理没有字体报空指针问题 RUN apk add --update ttf-dejavu fontconfig && rm -rf /var/cache/apk/*
完整dockerfile
FROM openjdk:8-jdk-alpine MAINTAINER jin820100449@qq.com RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \ && apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone && apk del tzdata \ && apk add --update ttf-dejavu fontconfig && rm -rf /var/cache/apk/* RUN mkdir /alidata && \ mkdir /alidata/app && \ mkdir /alidata/app/site && \ mkdir /alidata/app/site/log && \ mkdir /alidata/app/site/agent && \ mkdir /alidata/app/site/config VOLUME /alidata/app/site/log VOLUME /alidata/app/site WORKDIR /alidata/app/site ENV JAVA_OPTS="" ENV SW_OPTS="" ENV APP_PROFILE="test" COPY application.yml /alidata/app/site/config COPY application-test.yml /alidata/app/site/config ENTRYPOINT [ "sh", "-c", "java $SW_OPTS $JAVA_OPTS -jar /alidata/app/site/*.jar --spring.profiles.active=$APP_PROFILE -Dfile.encoding=utf-8"] COPY fosow-ctservice-0.0.1-SNAPSHOT.jar /alidata/app/site/fosow-ctservice-0.0.1-SNAPSHOT.jar ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone EXPOSE 8080