SpringBoot在集成activiti6时,保存流程图乱码

    @Bean
    public ProcessEngine processEngine(PlatformTransactionManager transactionManager, DataSource dataSource) throws IOException {
        SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
        //自动部署已有的流程文件
        Resource[] resources = new PathMatchingResourcePatternResolver().getResources(ResourceLoader.CLASSPATH_URL_PREFIX + "processes/*.bpmn");
        configuration.setDeploymentResources(resources);
        configuration.setTransactionManager(transactionManager);
        configuration.setDataSource(dataSource);
        configuration.setDatabaseSchemaUpdate("true");

        //使用这种方式不生效
        configuration.setActivityFontName("宋体");
        configuration.setAnnotationFontName("宋体");
        configuration.setLabelFontName("宋体");

        return configuration.buildProcessEngine();
    }

debug发现在程序运行时,使用的字体还是默认的 Arial

这时我们可以通过一下方式解决

@Configuration
public class ActivitiConfig implements ProcessEngineConfigurationConfigurer {

    /**
     * 解決工作流生成图片乱码问题
     *
     * @param processEngineConfiguration processEngineConfiguration
     */
    @Override
    public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {
        processEngineConfiguration.setActivityFontName("宋体");
        processEngineConfiguration.setAnnotationFontName("宋体");
        processEngineConfiguration.setLabelFontName("宋体");
    }
}

完整的项目地址:https://gitee.com/fuyang_lipengjun/platform-plus

转载于:https://my.oschina.net/u/2494315/blog/3024435

你可能感兴趣的:(SpringBoot在集成activiti6时,保存流程图乱码)