栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

1-JEECG集成FLOWABLE

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

1-JEECG集成FLOWABLE

flowable有驳回功能,单单就这点我感觉就比activiti强。

先展示集成效果:




后端 1、新建maven子工程,其中pom内容如下

这里我只列出与flowable有关的引用,我用的是6.5.0的版本


	4.0.0
	
		org.jeecgframework.boot
		d-twins-parent
		3.0.0
	
	d-twins-workflow

	
		
			org.flowable
			flowable-spring-boot-starter
			6.5.0
		
		
			org.flowable
			flowable-ui-modeler-rest
			6.5.0
			
				
					org.springframework.boot
					spring-boot-starter-log4j2
				
			
		
		
			org.flowable
			flowable-ui-modeler-conf
			6.5.0
		
		
			org.flowable
			flowable-rest
			6.5.0
		
		
			org.flowable
			flowable-ui-task-conf
			6.5.0
		
		
			org.flowable
			flowable-ui-admin-conf
			6.5.0
		
		
			org.flowable
			flowable-ui-idm-conf
			6.5.0
		
	

2、设置配置类
package org.jeecg.workflow.core.configuartion;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.rest.service.api.RestResponseFactory;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.flowable.spring.boot.FlowableSecurityAutoConfiguration;
import org.flowable.ui.common.service.exception.InternalServerErrorException;
import org.flowable.ui.common.service.idm.RemoteIdmService;
import org.flowable.ui.modeler.properties.FlowableModelerAppProperties;
import org.flowable.ui.modeler.rest.app.EditorGroupsResource;
import org.flowable.ui.modeler.rest.app.EditorUsersResource;
import org.flowable.ui.modeler.rest.app.ModelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;

import com.fasterxml.jackson.databind.ObjectMapper;

import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseConnection;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import lombok.extern.slf4j.Slf4j;

@Configuration
@EnableConfigurationProperties({ FlowableModelerAppProperties.class })
@ComponentScan(basePackages = { "org.flowable.ui.modeler.repository", "org.flowable.ui.modeler.service",
		"org.flowable.ui.common.service", "org.flowable.ui.common.repository", "org.flowable.ui.common.tenant",
		"org.flowable.ui.modeler.rest.app", "org.flowable.rest.service.api",
		"org.flowable.ui.task.service.debugger" }, excludeFilters = {
				@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = RemoteIdmService.class),
				@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ModelResource.class),
				@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = EditorUsersResource.class),
				@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = EditorGroupsResource.class),
				@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = FlowableSecurityAutoConfiguration.class) })
@Slf4j
public class FlowableConfiguration implements EngineConfigurationConfigurer {

	@Value("${spring.datasource.dynamic.datasource.master.url}")
	private String jdbcUrl;

	@Value("${spring.datasource.dynamic.datasource.master.driver-class-name}")
	private String jdbcDriverClassName;

	@Value("${spring.datasource.dynamic.datasource.master.username}")
	private String username;

	@Value("${spring.datasource.dynamic.datasource.master.password}")
	private String password;

	@Override
	public void configure(SpringProcessEngineConfiguration engineConfiguration) {
		engineConfiguration.setJdbcUrl(jdbcUrl);
		engineConfiguration.setJdbcDriver(jdbcDriverClassName);
		engineConfiguration.setJdbcUsername(username);
		engineConfiguration.setJdbcPassword(password);
	}

	@Autowired
	protected ObjectMapper objectMapper;

	@ConditionalOnMissingBean
	@Bean
	public RestResponseFactory restResponseFactory() {
		return new RestResponseFactory(objectMapper);
	}

	@Bean
	public Liquibase liquibase(DataSource dataSource) {
		log.info("Configuring Liquibase");
		Liquibase liquibase = null;
		try {
			DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());
			Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
			database.setDatabaseChangeLogTableName("ACT_DE_" + database.getDatabaseChangeLogTableName());
			database.setDatabaseChangeLogLockTableName("ACT_DE_" + database.getDatabaseChangeLogLockTableName());

			liquibase = new Liquibase("meta-INF/liquibase/flowable-modeler-app-db-changelog.xml",
					new ClassLoaderResourceAccessor(), database);
			liquibase.update("flowable");
			return liquibase;

		} catch (Exception e) {
			throw new InternalServerErrorException("Error creating liquibase database", e);
		} finally {
			closeDatabase(liquibase);
		}
	}

	private void closeDatabase(Liquibase liquibase) {
		if (liquibase != null) {
			Database database = liquibase.getDatabase();
			if (database != null) {
				try {
					database.close();
				} catch (DatabaseException e) {
					log.warn("Error closing database", e);
				}
			}
		}
	}

}

flowable配置还是很自由的, 实现接口EngineConfigurationConfigurer,可以注入数据库连接参数。

3、FlowbleSecurityConfiguration 放开springsecurity限制。
package org.jeecg.workflow.core.configuartion;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.firewall.DefaultHttpFirewall;
import org.springframework.security.web.firewall.HttpFirewall;

@Configuration
@EnableWebSecurity
public class FlowbleSecurityConfiguration extends WebSecurityConfigurerAdapter {

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		http.csrf().disable().authorizeRequests().antMatchers("xml/*Mapper.xml, classpath:/meta-INF/modeler-mybatis-mappings/*.xml
   configuration-properties:
     blobType: BLOB
     boolValue: true
     prefix: ''

最后表应该有83张

前端待写。。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/353896.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号