zoukankan      html  css  js  c++  java
  • Spring Boot整合Activiti,查看流程图出现中文乱码问题

    最近研究SpringBoot 整合Activiti时,实现流程图高亮追踪是出现中文乱码问题,找了很多方法,现在把我最后的解决方法提供给大家。

    Spring Boot是微服务快速开发框架,强调的是零配置,显然不推荐采用XML配置文件的方式解决。不使用Spring Boot的时候,

    是通过下面这种方式就可以解决

    ①原始解决方式:在Spring配置文件中的


    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">

    中加入两行代码:

    <property name="activityFontName" value="宋体"/>

    <property name="labelFontName" value="宋体"/>

    配置如下:

    <bean id="processEngineConfiguration"
    class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="activityFontName" value="宋体"/>
    <property name="labelFontName" value="宋体"/>
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="mailServerHost" value="localhost" />
    <property name="mailServerPort" value="5025" />
    <property name="jpaHandleTransaction" value="true" />
    <property name="jpaCloseEntityManager" value="true" />
    <property name="jobExecutorActivate" value="false" />
    </bean>

    ②Spring Boot中我采用的解决办法是,生成流程图的时候设置字体和编码信息解决,如下

    public void genPic(String procId) throws Exception {
    ProcessInstance pi = this.processEngine.getRuntimeService().createProcessInstanceQuery()
    .processInstanceId(procId).singleResult();
    BpmnModel bpmnModel = this.processEngine.getRepositoryService().getBpmnModel(pi.getProcessDefinitionId());
    List<String> activeIds = this.processEngine.getRuntimeService().getActiveActivityIds(pi.getId());
    ProcessDiagramGenerator p = new DefaultProcessDiagramGenerator();
    InputStream is = p.generateDiagram(bpmnModel, "png", activeIds, Collections.<String> emptyList(), "宋体", "宋体",
    null, 1.0);

    File file = new File("d:\Download\process.png");
    OutputStream os = new FileOutputStream(file);

    byte[] buffer = new byte[1024];
    int len = 0;
    while ((len = is.read(buffer)) != -1) {
    os.write(buffer, 0, len);
    }

    os.close();
    is.close();
    }

    转载请注明:http://www.xujin.org

  • 相关阅读:
    docker 方式安装gitlab时,项目的clone地址及项目文件列表地址为机器名的问题解决办法
    CPU流水线
    Element中el-form嵌套el-table双击编辑提交检验
    java基础知识
    C#多线程下载
    mysql优化
    C++ 算法(一)
    前端vue 的面试总结 以及答案以及前端技术点面试
    C# 组合任务
    C# List去重DistinctBy扩展
  • 原文地址:https://www.cnblogs.com/ACMer/p/4994407.html
Copyright © 2011-2022 走看看