如何将Activiti Modeler集成到自己的web应用程序中,并保留Maven建议的所有优点?
程序是Maven中的Activiti Modeler是Activiti Explorer的一部分。网上有几个问题来自想要开发自己的web应用程序、使用Modeler编辑流程但不需要其他资源管理器特性的人。
例如,Activiti BPM without activiti-explorer或How To Integrate Activiti Modeller Into own Web Application
发布于 2016-02-05 08:03:53
我使用Maven覆盖功能成功地做到了这一点:
1)包含资源管理器web应用程序的覆盖,但只包括Modeler文件:
pom.xml:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-webapp-explorer2</artifactId>
<version>${activiti-version}</version>
<type>war</type>
<scope>compile</scope>
</dependency>
....
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<overlays>
<overlay>
<groupId>org.activiti</groupId>
<artifactId>activiti-webapp-explorer2</artifactId>
<includes>
<include>WEB-INF/classes/stencilset.json</include>
<include>editor-app/**</include>
<include>modeler.html</include>
</includes>
</overlay>
</overlays>
</configuration>
</plugin>2)添加建模器Spring资源。它们用于检索和保存模型(注意:不是过程定义,这有点不同),还用于为模板集服务:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-modeler</artifactId>
<version>${activiti-version}</version>
</dependency>3)就是这样,但是它实际上不会在您的应用程序中工作,除非它被称为“activiti”。向项目中添加一个名为"editor-app/app-cfg.js“的文件,并在其中添加以下内容:
编辑器-app/app-cfg.js:
'use strict';
var ACTIVITI = ACTIVITI || {};
ACTIVITI.CONFIG = {
'contextRoot' : window.location.pathname.substring(0,window.location.pathname.lastIndexOf('/')),
};这实际上是本机app-cfg的一个副本,其中包含了上下文根奇怪的“//service”设置。我们将其更改为更通用的设置。它将用于从存储库中检索模型。我们的文件将覆盖浏览器webapp附带的文件。
备注:
( a)您必须自己管理流程定义到模型的转换。有关一个想法,请参见https://github.com/Activiti/Activiti/blob/activiti-5.19.0.1/modules/activiti-explorer/src/main/java/org/activiti/editor/ui/ConvertProcessDefinitionPopupWindow.java
b)我不得不避免在每件事上都使用一个Jackson对象Mapper,我还没有研究为什么这样做不起作用:
<bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper">
</bean>
<mvc:annotation-driven>
<!-- using the same objectMapper leads to stencilset resource being served as string -->
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="objectMapper" ref="objectMapper"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>不要这么做,也不要做更多的研究,因为这实际上破坏了为“activiti modeler”的一部分服务的模板。它开始将stencilset服务为格式错误的字符串,而不是普通的json。
c)我不知道如何在Modeler保存函数中插入CSRF安全头,所以我关闭了它--如果您不使用Security,就放弃它
https://stackoverflow.com/questions/35218832
复制相似问题