Springboot2集成Activiti,Activiti Modeler页面流程编辑器 (坑已踩)

记录一下重要的几个地方:

1.

//spring-boot-activiti 依赖


            org.activiti
            activiti-spring-boot-starter-basic
            ${activiti.version}
            
                
                    mybatis
                    org.mybatis
                
                
                    activation
                    javax.activation
                
            
        

        
            org.activiti
            activiti-spring-boot-starter-actuator
            ${activiti.version}
        

        
            org.activiti
            activiti-rest
            ${activiti.version}
        

 2.启动类忽略装配类

org.activiti.spring.boot.SecurityAutoConfiguration.class:
防止找不到 GlobalAuthenticationConfigurerAdapter

org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class:去除security的自动装配,当前项目中用了security可以不排除

@SpringBootApplication(exclude = {
        org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
        org.activiti.spring.boot.SecurityAutoConfiguration.class
})

3.avtiviti配置类

@Configuration
@Slf4j
public class ActitytiConfig extends AbstractProcessEngineAutoConfiguration {

    @Bean(name = "activitiDataSource")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource activitiDataSource(){
        log.info("activitiDataSource 初始化...");
        return new DruidDataSource();
    }

    // todo activiti单独配置数据源的情况下 配置多数据源事务一致

    /**
     * 使用默认配置数据源
     */
    @Autowired
    @Qualifier("dataSource")
    DataSource dataSource;
    /**
     * 统一事务
     */
    @Autowired
    @Qualifier("transactionManager")
    PlatformTransactionManager transactionManager;

    @Bean
    public SpringProcessEngineConfiguration springProcessEngineConfiguration() {
        SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
        configuration.setDataSource(dataSource)
                .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
                .setJobExecutorActivate(true);
        configuration.setTransactionManager(transactionManager);
        return configuration;
    }

}

activiti 数据源和事务管理跟项目中一致,如果需要单独配activiti数据源的话,要处理事务一致的问题。

 

具体配置步骤详情参考:https://blog.csdn.net/zhengyidi1357/article/details/80858865

具体代码实现:https://gitee.com/ermu0420/springboot-activiti

 

你可能感兴趣的:(spring,boot)