學習 Activiti5.13與springMVC整合,自學001期,springmvc整合mybatis

來源:互聯網
上載者:User

學習 Activiti5.13與springMVC整合,自學001期,springmvc整合mybatis

   公司有個業務需要使用到workflow 這東西,一直都沒接觸過,領導給了點時間讓我先研究研究。最開始打算使用jbpm,但是後面學習下來發現貌似jbpm預設支援的hibernate,我們工程使用mybatis做持久化的。後來問朋友除了jbpm還有其他的workflow外掛程式沒。朋友說activiti挺好使的,我網上找了點資料一看確實還不錯,感覺比jbpm輕量級一點,封裝比jbpm也成熟很多,與spring、mybatis很好的整合到一起,所以就學習了activiti,activiti也是基於jbpm進行的處理。

1 .首先,要去官網下載activiti的外掛程式包:

官網地址:下載activiti外掛程式包

2.下載好外掛程式之後,需要與eclipse或者其他IDE整合起來,我這邊使用的是eclipse,具體外掛程式安裝地址自行網上查詢。外掛程式裝好之後,點擊eclipse window--》preferences 可以看到

3. 將activiti通過spring進行初始化,這個主要是針對spring 的 application.xml,application.xml設定檔加入下面的映射資訊就可以了:

<!-- 載入activiti引擎 -->      <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">         <property name="processEngineConfiguration" ref="processEngineConfiguration" />      </bean>      <bean id="processEngineConfiguration"   class="org.activiti.spring.SpringProcessEngineConfiguration">         <property name="dataSource" ref="dataSource" />         <property name="transactionManager" ref="transactionManager" />         <property name="databaseSchemaUpdate" value="true" />         <property name="jobExecutorActivate" value="false" />      </bean>      <!-- activiti的各種服務介面 -->      <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />      <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />      <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />      <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />      <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />

4.資料來源自己配置

5.應用伺服器啟動之後會自動建立activiti所需要的相關表格:


6.可以寫一個測試小內容:

ProcessEngine pe = ProcessEngines.getDefaultProcessEngine();System.out.println(pe);RepositoryService reposit = pe.getRepositoryService();DeploymentBuilder deploy = reposit.createDeployment();deploy.addClasspathResource("/MyProcess.bpmn");deploy.deploy();        RuntimeService runtimeService = pe.getRuntimeService();         runtimeService.startProcessInstanceByKey("scripttask1");//啟動流程,ID必須與你配置的一致          System.out.println("ok......");  

運行輸出:

test

ok......


我也在學習中,有不對的地方還望各位大哥指導一哈~ 





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.