前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >flowable入门

flowable入门

作者头像
全栈程序员站长
发布2022-08-31 11:44:09
4430
发布2022-08-31 11:44:09
举报

大家好,又见面了,我是你们的朋友全栈君。

在使用 flowable框架的时候,首先需要引入 flowable的jar包,flowable maven仓库地址为:

<!– https://mvnrepository.com/artifact/org.flowable/flowable-engine –> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-engine</artifactId> <version>6.0.0.RC1</version> </dependency>

新建flowable.cfg.xml文件,如下图所示:

flowable入门
flowable入门

flowable.cfg.xml文件内容如下所示:

代码语言:javascript
复制
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   
       http://www.springframework.org/schema/beans/spring-beans.xsd">
       <!--分享牛http://www.shareniu.com/ -->
 <bean id="dataSource"  class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>jdbc:mysql://127.0.0.1:3306/shareniuflowable?useUnicode=true&characterEncoding=UTF-8
			</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password" value="" />
		<!--  -->
	</bean>
	<!--分享牛http://www.shareniu.com/ -->
        <bean id="processEngineConfiguration"
          class="org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration" >  
        <property name="dataSource" ref="dataSource" />  
         <property name="databaseSchemaUpdate" value="true" />  
        </bean>  
</beans>

新建测试类如下所示:

代码语言:javascript
复制
package com.shareniu.flowables.ch1;

import java.io.IOException;
import java.io.InputStream;

import org.flowable.engine.IdentityService;
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.DeploymentBuilder;
import org.junit.Before;
import org.junit.Test;

/**
 * 分享牛http://www.shareniu.com/ 
 *
 */
public class App 
{
	// 获取到Activiti ProcessEngine
		ProcessEngine processEngine = null;
		// 获取RepositoryService 实例对象
		RepositoryService repositoryService = null;
		// 资源名称
		String resourceName = "shareniu_addInputStream.bpmn";
		IdentityService identityService;
		RuntimeService runtimeService;
		TaskService taskService;
		@Before
		public void init() {
			InputStream in = App.class.getClassLoader().getResourceAsStream(
					"com/shareniu/flowables/ch1/flowable.cfg.xml");
			ProcessEngineConfiguration pcf = ProcessEngineConfiguration
					.createProcessEngineConfigurationFromInputStream(in);
			processEngine = pcf.buildProcessEngine();
			repositoryService = processEngine.getRepositoryService();
			identityService = processEngine.getIdentityService();
			runtimeService = processEngine.getRuntimeService();
			taskService = processEngine.getTaskService();
			ProcessEngineConfigurationImpl pc = (ProcessEngineConfigurationImpl) processEngine
					.getProcessEngineConfiguration();
		}
		@Test
		public void addInputStreamTest() throws IOException {
			// 定义的文件信息的流读取 分享牛http://www.shareniu.com/ 
			InputStream inputStream = App.class
					.getClassLoader().getResource("com/shareniu/flowables/ch1/common.bpmn").openStream();
			// 流程定义的分类 分享牛http://www.shareniu.com/ 
			String category = "shareniu_addInputStream";
			// 构造DeploymentBuilder对象
			DeploymentBuilder deploymentBuilder = repositoryService
					.createDeployment().category(category)
					.addInputStream(resourceName, inputStream);
			// 部署
			Deployment deploy = deploymentBuilder.deploy();
			System.out.println(deploy);

		}
		
}

运行上述代码,流程文档以及成功部署。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/143366.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年5月2,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档