首先我們在eclipse上創建一個maven項目
然后在resources下面創建一個file,並命名問activiti.cfg.xml
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/student" />
<property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
<property name="jdbcUsername" value="root" />
<property name="jdbcPassword" value="123456" />
<property name="databaseSchemaUpdate" value="true" />
</bean>
</beans>
然后新建一個包和一個類
執行以下代碼,自動會在數據庫創建25張表
//使用activiti.cfg.xml配置文件,引入配置文件一樣可以獲得流程引擎信息
@Test
public void testCreateTableWithXml(){
// 引擎配置
ProcessEngineConfiguration pec=ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
// 獲取流程引擎對象
ProcessEngine processEngine=pec.buildProcessEngine();
}