Activiti

Activiri和Spring或SpringBoot整合没生成历史表的解决办法

Activiti自动生成表没有生成历史表的解决办法!

在xml里加入以下的代码

<property name="dbHistoryUsed" value="true"/>

位置如下
在这里插入图片描述

在yml文件

db-history-used: true

位置如下:
在这里插入图片描述

Activiti-Spring.xml
<?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: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.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd
    ">
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<!-- 数据库驱动 -->
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
        <!-- 数据库连接 -->
        <property name="url" value="jdbc:mysql://localhost:3308/actspring?serverTimezone=Asia/Shanghai&amp;allowPublicKeyRetrieval=true&amp;useSSL=false&amp;nullCatalogMeansCurrent=true"/>
        <!-- 数据库用户名 -->
        <property name="username" value="root"/>
        <!-- 数据库密码 -->
        <property name="password" value="123456"/>
        <property name="maxActive" value="3"/>
        <property name="maxIdle" value="1"/>
	</bean>
	 <!-- 工作流引擎配置bean -->
	 <!-- activiti的核心交给Spring去处理 -->
    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
        <!-- 数据源 -->
        <property name="dataSource" ref="dataSource"/>
        <!-- 使用spring事务管理器 -->
        <property name="transactionManager" ref="transactionManager"/>
        <!-- 数据库策略 -->
        <!-- value 的值,flase activist启动时,表不匹配会报错(生产环境)create-drop activiti启动时创建表,关闭时删除表(测试环境) -->
        <property name="databaseSchemaUpdate" value="true"/>
        <property name="dbHistoryUsed" value="true"/>
    </bean>


    <!-- 流程引擎 -->
    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration"/>
    </bean>
    <!-- 资源服务service -->
    <bean id="repositoryService" factory-bean="processEngine"
          factory-method="getRepositoryService"/>
    <!-- 流程运行service -->
    <bean id="runtimeService" factory-bean="processEngine"
          factory-method="getRuntimeService"/>
    <!-- 任务管理service -->
    <bean id="taskService" factory-bean="processEngine"
          factory-method="getTaskService"/>
    <!-- 历史管理service -->
    <bean id="historyService" factory-bean="processEngine"
          factory-method="getHistoryService"/>

    <!-- 事务管理器 -->
    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!-- 通知 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <!-- 传播行为 -->
            <tx:method name="save*" propagation="REQUIRED"/>
            <tx:method name="insert*" propagation="REQUIRED"/>
            <tx:method name="delete*" propagation="REQUIRED"/>
            <tx:method name="update*" propagation="REQUIRED"/>
            <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
            <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
        </tx:attributes>
    </tx:advice>

    <!-- 切面,根据具体项目修改切点配置 -->
    <aop:config proxy-target-class="true">
        <aop:advisor advice-ref="txAdvice"
                     pointcut="execution(* com.itheima.ihrm.service.impl.*.*(..))"/>
    </aop:config>
</beans>
yml文件
spring:
   datasource:
      driver-class-name:
      url: jdbc:mysql://localhost:3308/actspring?serverTimezone=Asia/Shanghai&amp;allowPublicKeyRetrieval=true&amp;useSSL=false
      username: root
      password: 123456
   activit:
      #1.flase:默认值。activiti启动时,对比数据库保存的版本,如果没有表或者版本不匹配,将抛出异常
      #2.true:activiti会对数据库中所有表进行更新操作。如果表不存在,则会自动创建
      #3.create_drop:在activiti启动时创建表,在关闭时删除表(必须手动关闭引擎,才能删除表)
      #4.drop_create:在activiti启动时删除原来的表,然后在创建新表(不需要手动关闭引擎)
      database-sohema-update: true
      #检测历史信息表是否存在,activiti7默认不生成信息表,开启历史表
      db-history-used: true
      #历史记录存储等级
      #none:不保存任何的历史数据,因此才流程执行过程中,是最高效的
      #activity:级别高于none,保存流程实例与流程行为,其他数据不保存
      #audit:除activity级别会保存的数据外,还会保存全部的流程任务及其属性。audit为history的默认值
      #full:保存历史数据的最高级别,除了会保存audit级别的数据外,还会保存其他全部流程相关的细节数据,包括一些流程参数等
      history-leven: full
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值