The company has a business need to use to workflow this thing, has not been contacted, the leadership gave some time for me to study the first. Initially intended to use JBPM, but later learned to find that seemingly jbpm default support for Hibernate, our project uses MyBatis to do the persistence. Later asked friends in addition to jbpm there are other workflow development plugin did not. Friend said Activiti very good, I found a bit of information on the internet really good, feel lighter than jbpm, packaging than jbpm also mature a lot, with spring, MyBatis is well integrated together, so on learning Activiti, Activiti is also a process based on JBPM.
1. First, go to the official website to download the Activiti plugin package:
Website address: Download Activiti plug-in package
2. After downloading the plugin, you need to integrate with eclipse or other IDE, I use Eclipse, specific plug-in installation address on-line query. After the plugin is installed, click Eclipse window--Preferences to see
3. Initialize the Activiti through spring, which is mainly to add the following mapping information to the spring application.xml,application.xml configuration file:
<!--load Activiti engine--<bean id= "Processengine" class= "Org.activiti.spring.ProcessEngineFactoryBean" > <property name= "processengineconfiguration" ref= "processengineconfiguration"/> </bean> <bean Id= "Processengineconfiguration" class= "org.activiti.spring.SpringProcessEngineConfiguration" > <property n Ame= "DataSource" ref= "DataSource"/> <property name= "TransactionManager" ref= "TransactionManager"/> <property name= "Databaseschemaupdate" value= "true"/> <property name= "jobexecutoractivate" value= "FAL Se "/> </bean> <!--activiti Various service Interfaces--<bean id=" Repositoryservice "factory-bean=" proces Sengine "factory-method=" Getrepositoryservice "/> <bean id=" Runtimeservice "factory-bean=" processEngine "facto ry-method= "Getruntimeservice"/> <bean id= "Taskservice" factory-bean= "Processengine" factory-method= " Gettaskservice "/> <bean Id= "Historyservice" factory-bean= "Processengine" factory-method= "Gethistoryservice"/> <bean id= "managementSe Rvice "factory-bean=" Processengine "factory-method=" Getmanagementservice "/>
4. Data Source Configuration
5. When the application server starts, it will automatically create the related tables required by Activiti:
6. You can write a test small content:
Processengine PE = processengines.getdefaultprocessengine (); SYSTEM.OUT.PRINTLN (PE); Repositoryservice reposit = Pe.getrepositoryservice ();D Eploymentbuilder deploy = Reposit.createdeployment (); Deploy.addclasspathresource ("/MYPROCESS.BPMN");d Eploy.deploy (); Runtimeservice Runtimeservice = Pe.getruntimeservice (); Runtimeservice.startprocessinstancebykey ("Scripttask1");//Start the process, the ID must be consistent with your configuration System.out.println ("OK ...");
Run output:
Test
Ok......
I also in the study, has the wrong place also hoped that the elder brother guides a ha ~
Learning Activiti5.13 and SPRINGMVC integration, self-study phase 001