Activiti(六)SSH项目实战

1.1 创建项目

Activiti(六)SSH项目实战_第1张图片

1.2 添加Jar包

Activiti(六)SSH项目实战_第2张图片
1.3 更改配置文件

1.3.1 连接数据库

Activiti(六)SSH项目实战_第3张图片
1.3.2 Spring文件的配置

Activiti(六)SSH项目实战_第4张图片

2 项目配置

applicationContext-dao.xml

<bean id="employeeDao" class="cn.itcast.ssh.dao.impl.EmployeeDaoImpl" parent="baseDao">
bean>

<bean id="leaveBillDao" class="cn.itcast.ssh.dao.impl.LeaveBillDaoImpl" parent="baseDao">
bean>

这里说明一下:
parent=”baseDao”等同于

id="baseDao" abstract="true">
"sessionFactory"ref="sessionFactory">property>

这里写图片描述

applicationContext-service.xml

    <bean id="employeeService" class="cn.itcast.ssh.service.impl.EmployeeServiceImpl">
    <property name="employeeDao" ref="employeeDao">property>    
    bean>
    <bean id="leaveBillService" class="cn.itcast.ssh.service.impl.LeaveBillServiceImpl">
    <property name="leaveBillDao" ref="leaveBillDao">property> 
    bean>
    <bean id="workflowService" class="cn.itcast.ssh.service.impl.WorkflowServiceImpl">
    <property name="repositoryService" ref="repositoryService">property>
    <property name="runtimeService" ref="runtimeService">property>
    <property name="taskService" ref="taskService">property>
    <property name="formService" ref="formService">property>
    <property name="historyService" ref="historyService">property>
    <property name="leaveBillDao" ref="leaveBillDao">property>
    bean>

Activiti(六)SSH项目实战_第5张图片

applicationContext-action.xml

<bean id="loginAction" class="cn.itcast.ssh.web.action.LoginAction" scope="prototype">
<property name="employeeService" ref="employeeService">property>
bean>
<bean id="leaveBillAction" class="cn.itcast.ssh.web.action.LeaveBillAction" scope="prototype">
<property name="leaveBillService" ref="leaveBillService">property>
bean>
<bean id="workflowAction" class="cn.itcast.ssh.web.action.WorkflowAction" scope="prototype">
<property name="workflowService" ref="workflowService">property>
<property name="leaveBillService" ref="leaveBillService">property>
bean>

Activiti(六)SSH项目实战_第6张图片

activiti-context.xml,配置activiti表和事物以及service 不用创建流程引擎 直接引入就可以


<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">

<property name="dataSource" ref="dataSource" />

<property name="transactionManager" ref="transManager" />

<property name="databaseSchemaUpdate" value="true" />
bean>

<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="formService" factory-bean="processEngine" factory-method="getFormService" />

struts的配置

<struts>
    
    <constant name="struts.devMode" value="true" />
    
    <constant name="struts.ui.theme" value="simple" />

    <package name="default" namespace="/" extends="struts-default">
    
    <interceptors>
    
    <interceptor name="loginInterceptor" class="cn.itcast.ssh.utils.LoginInteceptor">interceptor>
    
    <interceptor-stack name="systemStack">
    <interceptor-ref name="defaultStack" />
    <interceptor-ref name="loginInterceptor" />
interceptor-stack>
    interceptors>

  
<default-interceptor-ref name="systemStack" /> 
    
    <global-results>
    <result name="login" type="redirect">
    login.jsp
    result>
    global-results>

    <action name="loginAction_*" class="loginAction" method="{1}">
        <result name="success">WEB-INF/views/main.jspresult>
        <result name="top">WEB-INF/views/top.jspresult>
        <result name="left">WEB-INF/views/left.jspresult>
        <result name="welcome">WEB-INF/views/welcome.jspresult>
        action>

        <action name="leaveBillAction_*" class="leaveBillAction" method="{1}">
            <result name="home">WEB-INF/views/leaveBill/list.jspresult>
            <result name="input">WEB-INF/views/leaveBill/input.jspresult>
            <result name="save" type="redirectAction">
        <param name="actionName">leaveBillAction_home.actionparam>
        result>
        action>

    <action name="workflowAction_*" class="workflowAction" method="{1}">
        <result name="list" type="redirectAction">
        <param name="actionName">workflowAction_deployHome.actionparam>
        result>
        <result name="deployHome">WEB-INF/views/workflow/workflow.jspresult>
        <result name="task">WEB-INF/views/workflow/task.jspresult>
        <result name="image">WEB-INF/views/workflow/image.jspresult>
        <result name="listTask" type="redirectAction">
    <param name="actionName">workflowAction_listTask.actionparam>
            result>
        <result name="viewTaskForm" type="redirectAction">
        <param name="actionName">/workflowAction_audit.actionparam>
        result>
        <result name="taskForm">WEB-INF/views/workflow/taskForm.jspresult>
            <result name="viewHisComment">WEB-INF/views/workflow/taskFormHis.jspresult>
        action>
    package>
struts>

Activiti(六)SSH项目实战_第7张图片

配置数据库表

Activiti(六)SSH项目实战_第8张图片

Activiti(六)SSH项目实战_第9张图片

3 流程图

Activiti(六)SSH项目实战_第10张图片

你可能感兴趣的:(Activiti(六)SSH项目实战)