Activiti中的流程配置文件类型可以分为以下两种:
1)普通配置,即Activiti的配置风格,通常情况下,使用该方式的文件名称为activiti.cfg.xml。
2)Spring配置,即Spring配置风格,使用该方式的文件名称可以自定义,例如activiti-context.xml、spring-activiti.xml等。
Activiti配置风格
activiti.cfg.xml配置文件的内容如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd ">
<!-- 定义一个id为processEngineConfiguration的流程引擎配置类,然后为它设置属性值 -->
<bean id="processEngineConfiguration"
class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- 数据库连接配置 -->
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti_test?
createDatabaseIfNotExist=true"></property>
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUsername" value="root"></property>
<property name="jdbcPassword" value="root"></property>
<!-- 建表策略 -->
<property name="databaseSchemaUpdate" value="true"></property>
<!-- 其它省略 -->
</bean>
</beans>
Spring配置风格
spring方式创建流程引擎与Activiti单独创建流程引擎是不一样的,区别在于:使用的引擎配置类不一样。
Activiti单独创