2. Activiti 支持的数据库
- 创建表方式
@Test
public void testGenTable() {
//1.创建ProcessEngineConfiguration对象
ProcessEngineConfiguration configurationFromResource = ProcessEngineConfiguration
.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
//2.创建ProcessEngine对象
ProcessEngine processEngine = configurationFromResource.buildProcessEngine();
//3.输出ProcessEngine对象
System.out.println(processEngine);
}
- activiti.cgf.xml
在 classpath 下创建 activiti.cgf.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
-instance"
"http://www.springframework.org/schema/context"
"http://www.springframework.org/schema/beans
beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema
xmlns:context=
xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/contex http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
</beans>
- 在activiti.xml中配置数据源和processEngineConfiguration
1) 数据源
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/activiti?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC"/>
<property name="username" value="root"/>
<property name="password" value="123"/>
<property name="maxActive" value="3"/>
<property name="maxIdle" value="1"/>
</bean>
2) processEngineConfiguration
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="dataSource" ref="dataSource"></property>
<property name="databaseSchemaUpdate" value="true"/>
</bean>
3)数据源和processEngineConfiguration
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti"/>
<property name="jdbcUsername" value="root"/>
<property name="jdbcPassword" value="root"/>
<property name="databaseSchemaUpdate" value="true"/>
</bean>