package org.jeecg.modules.flowable.config; import org.flowable.engine.ProcessEngine; import org.flowable.engine.ProcessEngineConfiguration; import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration; import org.flowable.eventregistry.impl.EventRegistryEngineConfiguration; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.flowable.eventregistry.impl.EventRegistryEngine; import javax.sql.DataSource; @Configuration public class FlowableConfig { @Value("${spring.datasource.dynamic.datasource.master.url}") private String jdbcUrl; @Value("${spring.datasource.dynamic.datasource.master.username}") private String jdbcUsername; @Value("${spring.datasource.dynamic.datasource.master.password}") private String jdbcPassword; @Value("${spring.datasource.dynamic.datasource.master.driver-class-name}") private String jdbcDriver; @Bean public DataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setUrl(jdbcUrl); dataSource.setUsername(jdbcUsername); dataSource.setPassword(jdbcPassword); dataSource.setDriverClassName(jdbcDriver); return dataSource; } @Bean(name = "processEngine") @DependsOn("dataSource") public ProcessEngine createProcessEngine(DataSource dataSource) { StandaloneProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration(); cfg.setDataSource(dataSource); cfg.setDatabaseType("mssql"); // 可以根据需要添加更多配置 cfg.setActivityFontName("宋体"); cfg.setLabelFontName("宋体"); cfg.setAnnotationFontName("宋体"); // 设置数据库模式更新策略为自动更新 cfg.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); return cfg.buildProcessEngine(); } @Bean(name = "eventRegistryEngine") public EventRegistryEngine eventRegistryEngine(DataSource dataSource) { EventRegistryEngineConfiguration config = new EventRegistryEngineConfiguration(); config.setDataSource(dataSource); // 设置数据库模式更新策略,这里选择自动更新 config.setDatabaseSchemaUpdate("true"); return config.buildEventRegistryEngine(); } }