SpringBoot整合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" />
springboot架构图</bean>
②Spring Boot中我采⽤的解决办法是,⽣成流程图的时候设置字体和编码信息解决,如下
public void genPic(String procId) throws Exception {
ProcessInstance pi = RuntimeService().createProcessInstanceQuery()
.processInstanceId(procId).singleResult();
BpmnModel bpmnModel = RepositoryService().ProcessDefinitionId()); List<String> activeIds = RuntimeService().Id()); 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();
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论