看了activiti官網使用文檔,看了前兩章還挺舒服的,看到第三章,忽然開始講配置了,一臉懵逼呀有木有,雖然部署好了activiti-app.war,可是仍是不清楚怎麼進行部署,啓動,給事件分配表單等。通過幾天的探索和搜索資料,如今將官網demo應用activiti-app.war的使用作了總結,並作了一點點的擴展-加入自定義的spring-mvc配置,以訪問自定義的controller,實現些自定義的業務前端
1、集成activiti-app到本身項目中java
1.1 解壓activiti-app.war,並將其中的前端文件和libs中的jar包copy到本身項目中
mysql
1.二、將web.xml 也copy到本身項目中
web
1.3 在resources目錄下新建spring-mvc.xml和META-INF/activiti-app/activiti-app.properties
spring
spring-mvc.xml配置以下sql
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> <!-- 自動掃描且只掃描@Controller --> <context:component-scan base-package="com.lab.controller" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <mvc:annotation-driven /> <mvc:default-servlet-handler /> </beans>
activiti-app.properties內容入下(須要修改成本身數據庫相應的配置)數據庫
datasource.driver=com.mysql.jdbc.Driver datasource.url=jdbc:mysql://192.168.34.36:3306/activiti6ui?useUnicode=true&characterEncoding=utf8&useSSL=false datasource.username=root datasource.password=root datasource.max-idle-time=100 #hibernate.dialect=org.hibernate.dialect.H2Dialect hibernate.dialect=org.hibernate.dialect.MySQLDialect #hibernate.dialect=org.hibernate.dialect.Oracle10gDialect #hibernate.dialect=org.hibernate.dialect.SQLServerDialect #hibernate.dialect=org.hibernate.dialect.DB2Dialect #hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
1.4 在web.xml中加入以下配置,全部以/lab/開頭的請求,都會走spring-mvc.xml中配置的controller
express
web.xml配置以下
spring-mvc
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> <listener> <listener-class>org.activiti.app.servlet.WebConfigurer</listener-class> </listener> <servlet> <servlet-name>springServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springServlet</servlet-name> <url-pattern>/lab/*</url-pattern> </servlet-mapping> </web-app>
2、activiti-app使用mvc
首先啓動應用,訪問 http://localhost:8080/activiti-app,進入到登陸頁面
輸入admin/test,就能夠進入到系統首頁
首先點擊菜單identity management,進入以下頁面,在該模塊中,建立兩個用戶lily和boss,如圖所示
而後進入到KickStart app,點擊進入kickstart App後,能夠建立和導入流程定義和表單等,咱們先建立兩個表單:一個請假表單,一個老闆批假表單,點擊forms菜單,分別建立兩個表單以下
建立完成後,點擊forms,能夠看到以下列表
接着,咱們來定義一個最簡單的請假流程:lily填寫假單,boss批假流程。
點擊processes菜單,而後點擊右上角的create process按鈕,就能夠進入到流程編輯器了
流程定義編輯器打開後,就能夠設計本身的流程了
單擊"請假單"事件時,能夠看到以下選項
單擊Assignments時,顯示以下圖所示:
單擊Referenced Form,顯示以下圖所示
選擇「員工請假單」便可
同理能夠完成「領導審批」事件對應的assignments和Referenced Form設置,設置完成後,保存便可
至此,流程定義已完成,接下來咱們要完成部署和啓動該流程。