Activiti 工作流引擎 ~ 整合 Activiti Modeler(一)
本文使用的Activiti版本為5.22.0。整理中。。。
解壓官方demo

遷移官方demo中的檔案到自己的項目中
1. 遷移前端檔案
将diagram-viewer、editor-app檔案夾和modeler.html檔案拷貝到自己項目的根目錄中
2.遷移配置檔案
3.遷移Java檔案
檔案可從源碼的
activiti-webapp-explorer2
子產品中擷取
内容調整
1.修改資料庫配置檔案
注意:
a. 此處需要将
jdbc.url
中的
&
改回為
&
,否則将導緻中文亂碼
b. 截圖中
utf-8
的後面多了一個
"
(雙引号),需要删除
2.修改activiti上下文路徑
3.activiti-custom-context.xml放開注釋部分
@Configuration
public class ActivitiEngineConfiguration {
//...
}
官方demo使用注解的方式配置
Activiti
環境,是以
activiti-custom-context.xml
中的配置被注釋掉了。這兩種方式可以任選,此處使用
xml
方式配置。
由于
Activiti
官方demo中使用
Vaadin
作為前端架構進行頁面展示,故需将頁面涉及到的背景重新編寫
Spring 配置
web.xml中關于activiti的配置
url-pattern的設定為
/service/*
是因為activiti-model中設定的路徑都是相對于
service
的,在
app-cfg.js
檔案中可修改其值
spring-mvc.xml中添加對靜态資源的處理
<!-- 靜态資源不走controller -->
<mvc:resources mapping="/diagram-viewer/**" location="/diagram-viewer/" />
<mvc:resources mapping="/editor-app/**" location="/editor-app/" />
activiti-custom-context.xml中添加bean
建立activiti-mvc.xml
<mvc:annotation-driven/>
<!-- 指定需要掃描的包 -->
<context:component-scan base-package="org.activiti.rest.editor,org.activiti.rest.diagram" />
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="language" />
</bean>
<bean id="requestMappingHandlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="useSuffixPatternMatch" value="false" />
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
添加依賴
Activiti
依賴
com.fasterxml.jackson.databind
包,maven配置如下:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.6</version>
</dependency>