我公司采用分布式敏捷架构zheng:https://gitee.com/shuzheng/zheng。不过,如果要让此架构支持activiti工作流,需要进行一定的配置。
一、打开zheng-common项目的pom.xml文件,添加activiti包。
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.14</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>5.14</version>
</dependency>
二、在
zheng-rpc-service资源项目里添加activiti.cfg.xml文件。内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="activityFontName" value="微软雅黑"></property>
<property name="dataSource" ref="dataSource"></property>
<property name="transactionManager" ref="transactionManager"></property>
<!-- 建表策略 -->
<property name="databaseSchemaUpdate" value="true"></property>
<!-- 历史控制级别 -->
<property name="history" value="full"></property>
</bean>
<bean id="processEngineFactoryBean" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration"></property>
</bean>
<bean id="repositoryService" factory-bean="processEngineFactoryBean" factory-method="getRepositoryService"></bean>
<bean id="runtimeService" factory-bean="processEngineFactoryBean" factory-method="getRuntimeService"></bean>
<bean id="taskService" factory-bean="processEngineFactoryBean" factory-method="getTaskService"></bean>
<bean id="historyService" factory-bean="processEngineFactoryBean" factory-method="getHistoryService"></bean>
<bean id="formService" factory-bean="processEngineFactoryBean" factory-method="getFormService"></bean>
<bean id="identityService" factory-bean="processEngineFactoryBean" factory-method="getIdentityService"></bean>
<bean id="managementService" factory-bean="processEngineFactoryBean" factory-method="getManagementService"></bean>
</beans>
三、在applicationContext-jdbc.xml文件添加一行导入资源代码:
<import resource="activiti.cfg.xml"/>
添加好后的示例如图所示: