springMVC集成activiti-explorer5.22(一)

1.搭建springMVC环境,此处就不在多说,略过...
2.解压缩activiti-explorer文件,复制activiti-explorer目录下面的diagram-viewer、editor-app、modeler.html三个文件到项目中,如图:

springMVC集成activiti-explorer5.22(一)

3.复制activiti-explorer项目classes目录下的stencilset.json文件到你的项目中,如图:

springMVC集成activiti-explorer5.22(一)

4.复制到项目中的目录结构如下(可自定义到其他位置),如图:

springMVC集成activiti-explorer5.22(一)

5.编写activiti的配置文件,并引入到spring的配置文件中启动,代码如下:
<?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-4.1.xsd
        http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc   http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">  
    <!-- 在线编辑器配置开始 -->  
    <bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper"/>  
    <!-- 在线编辑器配置结束 -->  
    <!-- activiti 配置开始 -->  
    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> 
        <!-- 注入数据库连接池 -->  
        <property name="dataSource" ref="dataSource"/>  
        <!-- 配置事物管理器 -->  
        <property name="transactionManager" ref="transactionManager"/>  
        <!-- 自动构建数据库表,设置value="true",第一次启动建表;设置value="drop-create",每次启动时建新表 -->  
        <property name="databaseSchemaUpdate" value="true"/>  
        <!--激活Timer和异步消息的线程的组件,即activiti的定时扫描任务,默认:true,不使用的话建议关掉 -->  
        <property name="jobExecutorActivate" value="false"/>  
        <!-- 生成流程图的字体 -->  
        <property name="activityFontName" value="宋体"/>  
        <property name="labelFontName" value="宋体"/>  
        <property name="annotationFontName" value="宋体"/>  
        <!-- UUID作为主键生成策略 -->  
        <!-- <property name="idGenerator" ref="uuidGenerator" /> -->  
        <!-- 自动部署,只有流程数据库中没有和自动部署的流程定义相同的记录才会部署 -->  
        <property name="deploymentResources"> 
            <list> 
                <value>classpath*:/deployments/*.bpmn</value>  
                <value>classpath*:/deployments/*.png</value> 
            </list> 
        </property> 
    </bean>  
    <!-- 创建流程引擎对象 -->  
    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean"> 
        <property name="processEngineConfiguration" ref="processEngineConfiguration"/> 
    </bean>  
    <!-- 创建activiti提供的各种服务 -->  
    <!-- 工作流仓储服务 -->  
    <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="formService" factory-bean="processEngine" factory-method="getFormService"/>  
    <!-- 提供基础的用户管理以及身份认证 -->  
    <bean id="IdentityService" factory-bean="processEngine" factory-method="getIdentityService"/>  
    <!-- activiti 配置结束 --> 
</beans>
6.spring核心配置文件如下:
<?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:jdbc="http://www.springframework.org/schema/jdbc"
 xmlns:jee="http://www.springframework.org/schema/jee"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns:util="http://www.springframework.org/schema/util"
 xmlns:task="http://www.springframework.org/schema/task"
 xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
     http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
     http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd">  
    <!-- 扫描activiti在线编辑器的跳转@RestController -->  
    <context:component-scan base-package="com" use-default-filters="false"> 
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> 
    </context:component-scan>  
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>  
        <property name="url" value="jdbc:mysql://localhost:3306/activiti_test"/>  
        <property name="username" value="root"/>  
        <property name="password" value="root"/>  
        <property name="defaultAutoCommit" value="false"/> 
    </bean>  
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
        <property name="dataSource" ref="dataSource"/> 
    </bean>  
    <!-- 配置 Annotation 驱动,扫描@Transactional注解的类定义事务  -->  
    <!-- <tx:annotation-driven transaction-manager="transactionManager" /> -->  
    <!-- 引入SpringMVC配置文件 -->  
    <import resource="applicationActiviti.xml"/> 
</beans>

7.springMVC的配置文件中不要忘记扫描controller,springMVC的配置(这里只贴必须配置,如需扩展请根据自己情况添加)如下:

<?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-4.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">  
    <!-- 1.启动注解,注册服务,如验证框架、全局类型转换器-->  
    <mvc:annotation-driven/>  
    <!-- 2.启动自动扫描,只加载controller的时候,不加载service,因为此时事物并未生效,若此时加载了service,那么事物无法对service进行拦截 -->  
    <context:component-scan base-package="com.hello"/>  
    <context:component-scan base-package="com.rest.editor"/>  
    <!-- 3.配置视图解析器 -->  
    <!-- 对转向视图的路径解析,在请求时对视图名称添加前后缀 -->  
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
        <property name="prefix" value="/views/"/>  
        <property name="suffix" value=".jsp"/>  
        <property name="contentType" value="text/html;charset=UTF-8"/> 
    </bean>  
    <!-- 4.对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->  
    <!-- 执行顺序是2147483646 -->  
    <mvc:default-servlet-handler/> 
</beans>
8.web.xml文件就不贴了,根据自己项目情况配置就好
9.至此,集成activiti-explorer的基本工作已经做好

转载于:https://blog.51cto.com/1197822/2157711

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值