集成activiti到现有项目中
1.在lib中添加相关的jar包
2.找到一个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.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,并将该文件放入其中,可以使用如下代码加载流程引擎:
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti123.cfg.xml").buildProcessEngine();
若是想把activiti.cfg.xml放到某个包下(如:org.activiti.resource),加载时需要指定路径才能访问到,不然会报找不到该文件
ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("org/activiti/resource/activiti.cfg.xml").buildProcessEngine();
百流积聚,江河是也;文若化风,可以砾石。