问题描述
1、流程图生成代码:
public InputStream showModelPicture(String modelId) {
Model modelData = repositoryService.getModel(modelId);
ObjectNode modelNode = null;
try {
modelNode = (ObjectNode) new ObjectMapper()
.readTree(repositoryService.getModelEditorSource(modelData.getId()));
} catch (IOException e) {
e.printStackTrace();
}
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
return diagramGenerator.generateDiagram(model,Collections.<String>emptyList());
}
2、流程图在本地环下(macOS,win环境下没有测试)显示正常,没有中文贴乱码,但是在docker和kuberntes环境下中文乱码。
3、乱码时dockerfile
FROM openjdk:11
COPY target/*.jar ./app.jar
CMD ["sh","-c","java $JAVA_OPTS -Xms512m -Xmx512m -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -Djava.security.egd=file:/dev/urandom -jar ./app.jar --server.port=8080 $PROJECT_OPTS"]
解决方法
修改dockerFile
1、更新基础镜像(检测基础镜像是否有/usr/share/fonts目录,有这个目录的基础镜像才有效)
2、将宋体字体文件拷贝到/usr/share/fonts目录下
FROM openjdk:11
COPY target/*.jar ./app.jar
# 配置字体
COPY simsun.ttf /usr/share/fonts/simsun.ttf
CMD ["sh","-c","java $JAVA_OPTS -Xms512m -Xmx512m -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -Djava.security.egd=file:/dev/urandom -jar ./app.jar --server.port=8080 $PROJECT_OPTS"]