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版本的包以后解决