我已经成功地使用 Maven 覆盖功能来做到这一点:
1) 包括 Explorer 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-explorer”。将一个名为“editor-app/app-cfg.js”的文件添加到您的项目中,并在其中添加以下内容:
编辑器应用程序/应用程序cfg.js:
'use strict';
var ACTIVITI = ACTIVITI || {};
ACTIVITI.CONFIG = {
'contextRoot' : window.location.pathname.substring(0,window.location.pathname.lastIndexOf('/')),
};
这实际上是本机 app-cfg 的副本,其中包含上下文根的奇怪“/activiti-explorer/service”设置。我们将其更改为更通用的设置。它将用于从存储库中检索模型。我们的文件将覆盖 Explorer Web 应用程序附带的文件。
Notes:
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)我必须避免使用一个杰克逊对象映射器来完成所有事情,我还没有研究为什么这不起作用:
<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”部分的模板集资源。它开始将模板集作为格式错误的字符串而不是正常的 json 提供服务。
c) 我不知道如何在 Modeler 保存功能中注入 CSRF 安全标头,所以我将其关闭 - 如果您不使用 Spring Security,请丢弃它