1.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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- <context:property-placeholder location="classpath:jdbc.properties"/> -->
<!-- 核心配置类,工作流配置信息 -->
<bean id="processEngineConfiguration"
class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- 数据源配置 -->
<!-- <property name="dataSource" ref="dataSource"></property> -->
<!-- 数据库连接信息 -->
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test"></property>
<property name="jdbcUsername" value="root"></property>
<property name="jdbcPassword" value="root123"></property>
<!-- 自动创建表 -->
<property name="databaseSchemaUpdate" value="true"></property>
<!-- 关闭JobExecutor的自动启动 -->
<property name="jobExecutorActivate" value="true"></property>
<!-- 配置自定义缓存 -->
<!-- <property name="processDefinitionCache">
<bean class="com.vclouds.workflow.cache.MyCache" />
</property> -->
<!-- 向表达式暴露bean,不写则为暴露所有,设置map值则表示暴露map中存在的bean -->
<!-- <property name="beans">
<map>
<entry key="printer" value-ref="printer" />
</map>
</property> -->
<!-- 邮件服务器配置 -->
<!-- <property name="mailServerHost" value="smtp.qq.com"></property>
<property name="mailServerUsername" value=""></property>
<property name="mailServerPassword" value=""></property>
<property name="mailServerPort" value="465"></property>
<property name="mailServerDefaultFrom" value=""></property>
<property name="mailServerUseSSL" value="true"></property>
<property name="useTLS"></property> -->
</bean>
<!-- 使用程序设置办理人 -->
<!-- <bean id="assign" class="com.com.Assign"></bean> -->
<!-- 使用表达式调用服务 -->
<bean id="execu" class="com.vclouds.servicetest.MyDelegate"></bean>
<!-- spring配置, -->
<!-- <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
数据源配置
<property name="dataSource" ref="dataSource"></property>
数据库连接信息
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test"></property>
<property name="jdbcUsername" value="root"></property>
<property name="jdbcPassword" value="root123"></property>
自动创建表
<property name="databaseSchemaUpdate" value="true"></property>
关闭JobExecutor的自动启动
<property name="jobExecutorActivate" value="false"></property>
配置自定义缓存
<property name="processDefinitionCache">
<bean class="com.vclouds.workflow.cache.MyCache" />
</property>
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
自动部署资源,default模式为所有资源打包,single-resource模式为每个资源单独打包,resource-parent-folder为同一上级目录下的打包
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="deploymentResources" value="classpath*:/activiti/*.bpmn" />
<property name="deploymentMode" value="single-resource" />
</bean>
利用工厂方式得到服务类对象
<bean id="repositoryService" factory-bean="processEngine"
factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine"
factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine"
factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine"
factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine"
factory-method="getManagementService" /> -->
</beans>
2.pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.activiti</groupId>
<artifactId>activiti</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>activiti</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mysql.connector>5.1.38</mysql.connector>
<activiti.version>5.20.0</activiti.version>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.21</slf4j.version>
<spring.version>4.3.2.RELEASE</spring.version>
</properties>
<dependencies>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- mysql连接配置 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector}</version>
</dependency>
<!-- activiti依赖配置 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- spring配置 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- spring-activiti集成 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>${activiti.version}</version>
</dependency>
</dependencies>
</project>