关闭

SpringMVC与Activiti网页流程设计器整合(一)

1493人阅读 评论(0) 收藏 举报
分类:

  • 下载activiti
官网下载activiti


源码在github上 地址 https://github.com/Activiti/Activiti

  • 执行数据库脚本
在database中执行对应数据库的脚本

  • 添加依赖文件

建Maven工程,取名为demo。在demo的pom文件中加入springMvc的依赖包,maven依赖如下。

 	<!-- Activiti -->
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-engine</artifactId>
			<version>${activiti.version}</version>
		</dependency>
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-spring</artifactId>
			<version>${activiti.version}</version>
		</dependency>
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-explorer</artifactId>
			<version>${activiti.version}</version>
			<exclusions>
				<exclusion>
					<artifactId>vaadin</artifactId>
					<groupId>com.vaadin</groupId>
				</exclusion>
				<exclusion>
					<artifactId>dcharts-widget</artifactId>
					<groupId>org.vaadin.addons</groupId>
				</exclusion>
				<exclusion>
					<artifactId>activiti-simple-workflow</artifactId>
					<groupId>org.activiti</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-modeler</artifactId>
            <version>${activiti.version}</version>
		</dependency>
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-diagram-rest</artifactId>
			<version>${activiti.version}</version>
		</dependency>
		<!--activiti end  -->

  •  整合前端文件

把前端的设计器文件从activiti-webapp-explorer2拷至我平台上新建的目录process-editor,如下图所示:


explorer2这个项目在启动后,就会spring mvc4进行包扫描,把(请参考org.activiti.explorer.servlet.DispatcherServletConfiguration),org.activiti.rest.editor、org.activiti.rest.diagram包下的Controller扫描至响应映射中来,为的就是实现编辑器及设计模型的流程展示时,相应有对应的controller服务。

 因此,我们比较好的办法就是重写这些controller即可,这些controller的实现也很简单,在这里,最简单的做法就是把这些类直接拷到项目中,重命名了包名。

拷完后,包如下所示:

 

 

controller 要扫描到activiti所在的包

  • 添加配置文件spring-activiti.xml

<!-- 加载配置属性文件 -->
	<context:property-placeholder ignore-unresolvable="true" location="classpath:sysconfig.properties" />
	<!-- 扫描activiti自带包 -->
	<context:component-scan base-package="com.rf.activiti.rest.editor" />
	<context:component-scan base-package="com.rf.activiti.rest.diagram" />


	<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
		<property name="dataSource" ref="dataSource" />
		<property name="transactionManager" ref="transactionManager" />
		<property name="deploymentResources" value="classpath*:/act/deployments/**/*.bar"/><!-- 自动部署 -->
		<property name="databaseSchemaUpdate" value="true" /><!-- 自动建表,自动更新表结构 -->
		<property name="jobExecutorActivate" value="false" /><!-- 该参数将启用定时相关的功能 -->
		<property name="history" value="full" /><!-- 历史记录保存模式 -->
		<!-- 生成流程图的字体 -->
		<property name="activityFontName" value="${activiti.diagram.activityFontName}"/>
		<property name="labelFontName" value="${activiti.diagram.labelFontName}"/>
		<property name="annotationFontName" value="${activiti.diagram.annotationFontName}"/><!-- 5.21.0 新增参数 -->
	</bean>
	<bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper" />
	<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
		<property name="processEngineConfiguration" ref="processEngineConfiguration" />
	</bean>
	<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" />
	<bean id="identityService" factory-bean="processEngine"
		factory-method="getIdentityService" />
	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

  • web.xml修改

  <servlet-mapping>
    <servlet-name>SpringMVC</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
     <servlet-name>SpringMVC</servlet-name>
     <url-pattern>/service/*</url-pattern>
  </servlet-mapping>

  • 修改 editor-app/app-cfg.js文件

ACTIVITI.CONFIG = {
'contextRoot' : '/dhcc-trans/service',
};
修改contextRoot 的名字为自己项目的名称,可动态获取项目的名称

  • stencilset.json 拷贝到resource中   
如果涉及汉化修改此文件






0
1

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:40210次
    • 积分:363
    • 等级:
    • 排名:千里之外
    • 原创:60篇
    • 转载:172篇
    • 译文:0篇
    • 评论:8条
    最新评论