集成activiti到現有項目中

1.在lib中添加相關的jar包java

2.找到一個activiti.cfg.xml,如果想用現有的數據庫須要配置mysql

<?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.StandaloneInMemProcessEngineConfiguration">
		<property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&characterSetResults=utf-8"></property>
		<property name="jdbcUsername" value="root"></property>
		<property name="jdbcPassword" value="foresight"></property>
		<property name="databaseSchemaUpdate" value="true"/>
	</bean>
</beans>

  而且在eclipse中畫出bpmn2.0流程圖,要想默認可以加載到activiti.cfg.xml須要把該文件放在根目錄src下,或者新建一個source folder,並將該文件放入其中,可使用以下代碼加載流程引擎:spring

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti123.cfg.xml").buildProcessEngine();

如果想把activiti.cfg.xml放到某個包下(如:org.activiti.resource),加載時須要指定路徑才能訪問到,否則會報找不到該文件sql

ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/resource/activiti.cfg.xml").buildProcessEngine();
相關文章
相關標籤/搜索