Springboot+activity6+mybatis-plus+dynamic多数据源配置

3 篇文章 0 订阅
1 篇文章 0 订阅

话不多说直接上干货

  1. 添加依赖
<dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-core</artifactId>
            <version>3.3.0</version>
        </dependency>
        <!-- 多数据源 依赖 -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
            <version>3.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-extension</artifactId>
            <version>3.3.0</version>
        </dependency>
        <!-- mybatisplus 依赖 -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-spring-boot-starter-basic</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis</artifactId>
                </exclusion>
            </exclusions>
            <version>6.0.0</version>
        </dependency>

2、配置文件

spring.datasource.dynamic.primary=master
spring.datasource.dynamic.strict=false
spring.datasource.dynamic.master.type= com.alibaba.druid.pool.DruidDataSource
spring.datasource.dynamic.datasource.master.driver-class-name=org.postgresql.Driver
spring.datasource.dynamic.datasource.master.jdbc-url=jdbc:postgresql://你的ip:5432/projectmonitoring?useUnicode=true&characterEncoding=utf8
spring.datasource.dynamic.datasource.master.username=你的用户
spring.datasource.dynamic.datasource.master.password=你的密码

spring.datasource.dynamic.test.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.dynamic.datasource.test.driver-class-name=org.postgresql.Driver
spring.datasource.dynamic.datasource.test.jdbc-url=jdbc:postgresql://你的ip:5432/activity?useUnicode=true&characterEncoding=utf8
spring.datasource.dynamic.datasource.test.username=你的用户
spring.datasource.dynamic.datasource.test.password=你的密码

3、编写配置文件

@Configuration
public class ActivitiConfig extends AbstractProcessEngineAutoConfiguration {
    @Bean
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.master")
    public DataSource masterDataSource() {
        DataSource build = DataSourceBuilder.create().build();
        return build;
    }
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.test")
    public DataSource activitiDataSource() {
        DataSource build2 = DataSourceBuilder.create()
                .build();
        System.out.println(" =流程数据源= ");
        return build2;
    }
    @Bean
    public SpringProcessEngineConfiguration springProcessEngineConfiguration(PlatformTransactionManager transactionManager, SpringAsyncExecutor springAsyncExecutor) throws IOException {
        //SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
        return baseSpringProcessEngineConfiguration(
                activitiDataSource(),
                transactionManager,
                springAsyncExecutor);
    }
}

4、新建bpmn文件
在这里插入图片描述
点击bpmn文件右键用viem bpmn()Diagram打开
在这里插入图片描述
5、绘制流程图

idea绘制Activiti流程图

6、流程图画好之后如下

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
  <process id="leave" name="请假流程" isExecutable="true">
    <startEvent id="sid-b694ca06-9c97-416a-9b75-5b3f1388f386" name="开始"/>
    <userTask id="sid-88e9a927-0231-4eb0-94b1-74dec5435158" name="提交请假申请"/>
    <sequenceFlow id="sid-131350b7-29bf-40f8-a78d-383fa9b28b91" sourceRef="sid-b694ca06-9c97-416a-9b75-5b3f1388f386" targetRef="sid-88e9a927-0231-4eb0-94b1-74dec5435158"/>
    <userTask id="sid-653f30eb-9132-4ecd-ba10-53865e3d0e49" name="经理审批"/>
    <sequenceFlow id="sid-97919194-7e5f-43c0-b2aa-2d005c0eaf84" sourceRef="sid-88e9a927-0231-4eb0-94b1-74dec5435158" targetRef="sid-653f30eb-9132-4ecd-ba10-53865e3d0e49"/>
    <exclusiveGateway id="sid-69e3eade-0d81-4aa2-9713-132125019ef5"/>
    <sequenceFlow id="sid-4dc2a577-5fd5-4c19-a470-5a62aaa0a9b1" sourceRef="sid-653f30eb-9132-4ecd-ba10-53865e3d0e49" targetRef="sid-69e3eade-0d81-4aa2-9713-132125019ef5"/>
    <sequenceFlow id="sid-f5f6a541-098c-4f54-aa36-0c2d96289005" sourceRef="sid-69e3eade-0d81-4aa2-9713-132125019ef5" targetRef="sid-88e9a927-0231-4eb0-94b1-74dec5435158" name="驳回">
      <conditionExpression xsi:type="tFormalExpression">${type==不同意}</conditionExpression>
    </sequenceFlow>
    <userTask id="sid-845290bc-5469-4796-bbde-d6f2e8add62b" name="财务审批"/>
    <sequenceFlow id="sid-2a334b60-f419-4a02-b362-a57ecbd655a5" sourceRef="sid-69e3eade-0d81-4aa2-9713-132125019ef5" targetRef="sid-845290bc-5469-4796-bbde-d6f2e8add62b" name="同意">
      <conditionExpression xsi:type="tFormalExpression">${type==同意}</conditionExpression>
    </sequenceFlow>
    <endEvent id="sid-583670cf-3d80-4433-b98d-2d1d52b85ce6"/>
    <sequenceFlow id="sid-db060abb-1ab4-4510-8b1e-8d581199bbdb" sourceRef="sid-845290bc-5469-4796-bbde-d6f2e8add62b" targetRef="sid-583670cf-3d80-4433-b98d-2d1d52b85ce6"/>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_leave">
    <bpmndi:BPMNPlane bpmnElement="leave" id="BPMNPlane_leave">
      <bpmdi:BPMNShape xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="shape-96f76f8e-9be0-467c-af18-87a8180dc0f3" bpmnElement="sid-b694ca06-9c97-416a-9b75-5b3f1388f386">
        <omgdc:Bounds x="-67.75" y="-78.0" width="30.0" height="30.0"/>
      </bpmdi:BPMNShape>
      <bpmdi:BPMNShape xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="shape-117e695f-b1b9-408d-9e5d-1f7f66b21027" bpmnElement="sid-88e9a927-0231-4eb0-94b1-74dec5435158">
        <omgdc:Bounds x="-102.75" y="-3.0" width="100.0" height="80.0"/>
      </bpmdi:BPMNShape>
      <bpmdi:BPMNEdge xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="edge-eb221ebb-8cb2-46ed-b94f-c9aff396af66" bpmnElement="sid-131350b7-29bf-40f8-a78d-383fa9b28b91">
        <omgdi:waypoint x="-52.75" y="-48.0"/>
        <omgdi:waypoint x="-52.75" y="-3.0"/>
      </bpmdi:BPMNEdge>
      <bpmdi:BPMNShape xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="shape-1e8ea135-9ded-4d37-b72b-d912bd0b351a" bpmnElement="sid-653f30eb-9132-4ecd-ba10-53865e3d0e49">
        <omgdc:Bounds x="-102.75" y="114.5" width="100.0" height="80.0"/>
      </bpmdi:BPMNShape>
      <bpmdi:BPMNEdge xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="edge-991f4bd3-0d65-410e-8698-893cee492aed" bpmnElement="sid-97919194-7e5f-43c0-b2aa-2d005c0eaf84">
        <omgdi:waypoint x="-52.75" y="77.0"/>
        <omgdi:waypoint x="-52.75" y="114.5"/>
      </bpmdi:BPMNEdge>
      <bpmdi:BPMNShape xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="shape-6bd363f1-f6d5-44e7-963e-690b7fbedcfb" bpmnElement="sid-69e3eade-0d81-4aa2-9713-132125019ef5">
        <omgdc:Bounds x="148.99402" y="134.5" width="40.0" height="40.0"/>
      </bpmdi:BPMNShape>
      <bpmdi:BPMNEdge xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="edge-9b643f74-4e3d-4b2e-8f7c-013ad6b318aa" bpmnElement="sid-4dc2a577-5fd5-4c19-a470-5a62aaa0a9b1">
        <omgdi:waypoint x="-2.75" y="154.5"/>
        <omgdi:waypoint x="148.99402" y="154.5"/>
      </bpmdi:BPMNEdge>
      <bpmdi:BPMNEdge xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="edge-e47b8bb6-357a-4041-8560-ebfd231aaefd" bpmnElement="sid-f5f6a541-098c-4f54-aa36-0c2d96289005">
        <omgdi:waypoint x="168.99402" y="134.5"/>
        <omgdi:waypoint x="-2.75" y="57.0"/>
      </bpmdi:BPMNEdge>
      <bpmdi:BPMNShape xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="shape-1ac26b02-4104-4faf-8084-1afa832e458a" bpmnElement="sid-845290bc-5469-4796-bbde-d6f2e8add62b">
        <omgdc:Bounds x="301.27405" y="114.49999" width="100.0" height="80.0"/>
      </bpmdi:BPMNShape>
      <bpmdi:BPMNEdge xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="edge-e8603e30-2079-45e2-bfa8-0b26957d027e" bpmnElement="sid-2a334b60-f419-4a02-b362-a57ecbd655a5">
        <omgdi:waypoint x="188.99402" y="154.5"/>
        <omgdi:waypoint x="301.27405" y="154.5"/>
      </bpmdi:BPMNEdge>
      <bpmdi:BPMNShape xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="shape-c9f0531d-62e9-4343-b6b2-ac6078224e28" bpmnElement="sid-583670cf-3d80-4433-b98d-2d1d52b85ce6">
        <omgdc:Bounds x="469.75406" y="139.5" width="30.0" height="30.0"/>
      </bpmdi:BPMNShape>
      <bpmdi:BPMNEdge xmlns:bpmdi="http://www.omg.org/spec/BPMN/20100524/DI" id="edge-d3a55233-4b77-4a94-985d-ead9935710c5" bpmnElement="sid-db060abb-1ab4-4510-8b1e-8d581199bbdb">
        <omgdi:waypoint x="401.27405" y="154.5"/>
        <omgdi:waypoint x="469.75406" y="154.5"/>
      </bpmdi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

在这里插入图片描述
7、点击启动按钮启动项目流程部署成功
相应表格生成

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一叶飘零晋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值