IDEA中使⽤activiti⼯作流安装插件actiBPM
点击左上⾓的File -> setting -> plugin -> market splace
输⼊actiBPM,搜索并安装即可。
⼀、actiBPM的搭建,融合Spring
1、创建maven项⽬
附上我的l
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0"
xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>com.sxt</groupId>
<artifactId>activiti_demo2</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<slf4j.version>1.6.6</slf4j.version>
<log4j.version>1.2.12</log4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>7.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>7.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-model</artifactId>
<version>7.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-converter</artifactId>
<version>7.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-json-converter</artifactId>
<version>7.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-layout</artifactId>
idea debug<version>7.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.activiti.cloud</groupId>
<artifactId>activiti-cloud-services-api</artifactId>
<version>7.0.0.Beta1</version>
<version>7.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!--log4j-->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- log end -->
<dependency>
<groupId&batis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.6</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>alfresco</id>
<name>Activiti Releases</name>
<url>artifacts.alfresco/nexus/content/repositories/activiti-releases/</url> <releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>
2、画图:
创建bpmn⽂件。
3、创建PNG⽂件
先将bpmn⽂件重命名为xml⽂件,右键选择diagram.
point:如果没有diagram选项,到plugin中查打开diagram(gradle 插件是否打开)
⼆、API的基本使⽤
⾸先创建配置⽂件。
1、log4j.properties
# Set root category priority to INFO and its only appender to CONSOLE.
#Category=INFO, CONSOLE debug info warn error fatal
# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
prise=FATAL, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %-6r
[%15.15t] %-5p %30.30c %x - %m\n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=d:\axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %-6r
[%15.15t] %-5p %30.30c %x - %m\n
2、l
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="/schema/beans"
xmlns:xsi="/2001/XMLSchema-instance"
xmlns:context="/schema/context"
xmlns:tx="/schema/tx"
xsi:schemaLocation="/schema/beans
/schema/beans/spring-beans.xsd
/schema/contex
/schema/context/spring-context.xsd
/schema/tx
/schema/tx/spring-tx.xsd">
<!--database数据源-->
<bean id="dataSource" class="org.apachemons.dbcp.BasicDataSource">
<property name="driverClassName" value="sql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/activiti" />
<property name="username" value="root" />
<property name="password" value="****" />
<property name="maxActive" value="3" />
<property name="maxIdle" value="1" />
</bean>
<!--创建processEngine-->
<bean id="processEngineConfiguration" class="ine.impl.cfg.StandaloneProcessEngineConfiguration"> <!--数据源-->
<property name="dataSource" ref="dataSource"/>
<!--activiti数据库表处理策略-->
<property name="databaseSchemaUpdate" value="true"/>
</bean>
</beans>
三、项⽬实战
不多说了,上代码:
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import ine.*;
import pository.Deployment;
import ine.runtime.ProcessInstance;
import ine.task.Task;
import org.junit.Test;
import java.io.InputStream;
import flect.Method;
import java.util.Iterator;
import java.util.List;
public class TestConnect {
//@Test
public ProcessEngine createTable(){
//加载配置⽂件,创建ProcessEngineConfiguration
ProcessEngineConfiguration processEngineConfiguration = ateProcessEngineConfigurationFromResource("l")
//创建engine和数据库建表
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
System.out.println(processEngine);
// //创建RuntimeService activiti的流程运⾏管理类
// RuntimeService runtimeService = RuntimeService();
// //创建TaskService activiti的任务管理类
// TaskService taskService = TaskService();
// //创建HistoryService activiti的历史管理类
// HistoryService historyService = HistoryService();
// //创建ManagementService activiti的引擎管理类
// ManagementService managementService = ManagementService();
return processEngine;
}
//部署流程定义
//@Test
public Deployment doDeployment(ProcessEngine processEngine){
//获取repositoryService
RepositoryService repositoryService = RepositoryService();
//加载BPMN⽂件部署对象
Deployment deploy = ateDeployment()
//加载BPMN⽂件
.addClasspathResource("holiday.bpmn")
.addClasspathResource("holiday.png").name("请假申请流程").deploy();
System.out.println("");
System.out.println("流程部署ID:"+Id());
System.out.println("流程部署名称:"+Name());
return deploy;
}
//启动流程实例
@Test
public void startProcessInstance(){
//创建流程引擎
ProcessEngine processEngine = createTable();
//流程部署
Deployment deployment = doDeployment(processEngine);
//获取RuntimeService
RuntimeService runtimeService = RuntimeService();
/
/根据流程定义KEY启动流程
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holiday");
System.out.println("流程定义ID:"+ProcessDefinitionId());
System.out.println("流程实例ID:"+Id());
System.out.println("当前活跃ID:"+ActivityId());
}
//查询⾓⾊当前待执⾏的任务
//这段代码需要BPMN⽂件⾥的UserTask设置了Assignee对象,我这⾥设定的是zhangsan
@Test
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论