已有項目集成activiti工作流

1.將lib.jar解壓,然後將裏的包拷貝到項目的lib中

activiti5.22.0:https://download.csdn.net/download/lhw244/11999129

activiti5.15:https://download.csdn.net/download/lhw244/12013969

2.web.xml中修改爲

<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:spring-*.xml,classpath*:activiti.cfg.xml</param-value>
	</context-param>

3.創建activiti配置文件activiti.cfg.xml,和spring-*.xml放在一個目錄下,修改裏面的數據庫配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        ">
    
    <!-- 第一種配置方法,注意不同數據庫driver和url的寫法 -->
	<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
        <property name="jdbcDriver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property>
        <property name="jdbcUrl" value="jdbc:sqlserver://192.168.1.110:1433;database=house"></property>
        <property name="jdbcUsername" value="sa"></property>
        <property name="jdbcPassword" value="sa"></property>
        <property name="databaseSchemaUpdate" value="true"/>
    </bean>

    <!--第二種配置方法,啓動正常,後續報錯
    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
        <property name="dataSource" ref="dataSource"/>
        <property name="transactionManager" ref="transactionManager"/>
        <property name="databaseSchemaUpdate" value="true"/>
        <property name="jobExecutorActivate" value="false"/>
        <property name="activityFontName" value="宋體"/>
        <property name="labelFontName" value="宋體"/>
    </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="managementService" factory-bean="processEngine" factory-method="getManagementService"/>

</beans>

附上不同數據庫時jdbcdriver和jdbcurl的寫法

 3 # HSQLDB #
 4 ##########
 5 jdbc.driverClassName=org.hsqldb.jdbcDriver
 6 jdbc.url=jdbc:hsqldb:hsql://localhost:9001/bookstore
 7 jdbc.username=sa
 8 jdbc.password=sa
 9 ###########
10 # MySQL 5 #
11 ###########
12 jdbc.driverClassName=com.mysql.jdbc.Driver
13 jdbc.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=GBK
14 jdbc.username=root
15 jdbc.password=root
16 ##############
17 # PostgreSQL #
18 ##############
19 jdbc.driverClassName=org.postgresql.Driver
20 jdbc.url=jdbc:postgresql://localhost/bookstore
21 jdbc.username=sa
22 jdbc.password=sa
23 ##########
24 # Oracle #
25 ##########
26 jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
27 jdbc.url=jdbc:oracle:thin:@192.168.1.250:1521:devdb
28 jdbc.username=HFOSPSP
29 jdbc.password=HFOSPSP
30 #############################
31 # MS SQL Server 2000 (JTDS) #
32 #############################
33 jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver
34 jdbc.url=jdbc:jtds:sqlserver://localhost:1433/bookstore
35 jdbc.username=sa
36 jdbc.password=sa
37 ##################################
38 # MS SQL Server 2000 (Microsoft) #
39 ##################################
40 jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
41 jdbc.url=jdbc:sqlserver://192.168.1.130:1433;database=ahos;user=sa;password=ahtec";
42 jdbc.username=sa
43 jdbc.password=ahtec
44 ########
45 # ODBC #
46 ########
47 jdbc.driverClassName=sun.jdbc.odbc.JdbcOdbcDriver
48 jdbc.url=jdbc:odbc:bookstore
49 jdbc.username=sa
50 jdbc.password=sa

4.啓動項目,如果數據庫多了act的表則基本配置成功

5.注:換項目時配置報錯,發現是activiti版本問題。新項目本來的spring爲4.09,換上activit5.15版本的包以後解決

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章