activiti6使用

1.下载acitiviti6

官网慢的话,到百度网盘搜索

idea按住嗯actiBPM插件

2.创建boot项目

依赖


    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.3.RELEASE
    

    
        
            mysql
            mysql-connector-java
            5.1.47
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.activiti
            activiti-spring-boot-starter-basic
            6.0.0
        
        
            org.springframework.boot
            spring-boot-starter-jdbc
        
        
            org.projectlombok
            lombok
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.3.1
        
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

配置文件
application.yml

spring:
  profiles:
    active: dev

server:
  port: 9005

application-dev.yml


spring:
  datasource:
    url: jdbc:mysql://localhost:3306/activiti?characterEncoding=utf-8&useSSL=false&useUnicode=true&zeroDateTimeBehavior=convertToNull
    username: root
    password: 123456
    driver-class-name: com.mysql.jdbc.Driver
    filters: stat
    maxActive: 20
    initialSize: 1
    maxWait: 60000
    minIdle: 1
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: select 'x'
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
    maxOpenPreparedStatements: 20
    hikari.minimum-idle: 5
    hikari.maximum-pool-size: 150
    hikari.connection-test-query: SELECT 1
    hikari.max-lifetime: 1800000
    hikari.connection-timeout: 30000
    # 空闲连接存活最大时间,默认600000(10分钟)
    hikari.idle-timeout: 1800000
  activiti:
    check-process-definitions: false #自动检查、部署流程定义文件
    database-schema-update: false #自动更新数据库结构
    #流程定义文件存放目录
    process-definition-location-prefix: classpath:/processes/
    #process-definition-location-suffixes: #流程文件格式
    history-level: full

resources下面创建processes文件夹,并且创建一个bpmn文件,可以使空的。
在这里插入图片描述
activiti6使用_第1张图片
启动类

@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

项目启动成功

数据源boot自动配置的,不需要自己配置
流程引擎也自动有了,可以直接注入引擎的接口

@Autowired
private RuntimeService runtimeService;
 
@Autowired
private TaskService taskService;
 
@Autowired
private IdentityService identityService;
 
@Autowired
private RepositoryService repositoryService;
 
@Autowired
private ProcessEngine processEngine;
 
@Autowired
private HistoryService historyService;

3.画流程图

id必须用英文,名称可以用中文
activiti6使用_第2张图片
复制出来,改为xml文件
选择xml文件,右键选择show bpmn2.0 designer
activiti6使用_第3张图片
选择export to file,存储到当前目录,为leave.png。等一会,才会显示出来
activiti6使用_第4张图片

4.流程定义


@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private RepositoryService repositoryService;

    @GetMapping("/deploy")
    public Object deploy() {
        DeploymentBuilder deployment = repositoryService.createDeployment();

        //图片必须指定
        Deployment test = deployment.name("test")
                .addClasspathResource("processes/leave.bpmn")
                .addClasspathResource("processes/leave.png")
                .deploy();
        return test.getId();
    }
}

设计三张表act_re_deployment,act_re_procdef,act_ge_bytearray
activiti6使用_第5张图片
activiti6使用_第6张图片
查看-图像,选择bytes列,即可看到图片
activiti6使用_第7张图片

你可能感兴趣的:(框架)