SpringBoot集成Flowable UI

专题导航

一、Flowable介绍及部署
二、SpringBoot集成Flowable UI
三、Flowable UI跳过权限验证
四、Flowable UI整合前后分离

一、引入Flowable UI相关依赖及springboot、mybatis

	<properties>
        <java.version>1.8java.version>
        <flowable.version>6.4.0flowable.version>
        <mybatis-spring-boot>1.3.1mybatis-spring-boot>
    properties>
	<dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>
        
        <dependency>
            <groupId>org.flowablegroupId>
            <artifactId>flowable-spring-boot-starter-basicartifactId>
            <version>${flowable.version}version>
        dependency>
        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>8.0.11version>
        dependency>

        
        <dependency>
            <groupId>org.mybatis.spring.bootgroupId>
            <artifactId>mybatis-spring-boot-starterartifactId>
            <version>${mybatis-spring-boot}version>
        dependency>
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>druidartifactId>
            <version>1.0.31version>
        dependency>
        <dependency>
            <groupId>log4jgroupId>
            <artifactId>log4jartifactId>
            <version>1.2.17version>
        dependency>
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>fastjsonartifactId>
            <version>1.2.46version>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-thymeleafartifactId>
        dependency>
        <dependency>
            <groupId>org.flowablegroupId>
            <artifactId>flowable-ui-commonartifactId>
            <version>${flowable.version}version>
        dependency>
        <dependency>
            <groupId>org.flowablegroupId>
            <artifactId>flowable-ui-modeler-restartifactId>
            <version>${flowable.version}version>
        dependency>
        <dependency>
            <groupId>org.flowablegroupId>
            <artifactId>flowable-idm-spring-configuratorartifactId>
            <version>${flowable.version}version>
        dependency>
        <dependency>
            <groupId>org.flowablegroupId>
            <artifactId>flowable-ui-idm-restartifactId>
            <version>${flowable.version}version>
        dependency>
        <dependency>
            <groupId>org.flowablegroupId>
            <artifactId>flowable-ui-idm-confartifactId>
            <version>${flowable.version}version>
        dependency>
        <dependency>
            <groupId>org.liquibasegroupId>
            <artifactId>liquibase-coreartifactId>
            <version>3.6.2version>
        dependency>

        
        <dependency>
            <groupId>org.springframework.securitygroupId>
            <artifactId>spring-security-coreartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.securitygroupId>
            <artifactId>spring-security-configartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.securitygroupId>
            <artifactId>spring-security-cryptoartifactId>
        dependency>
        <dependency>
            <groupId>org.springframework.securitygroupId>
            <artifactId>spring-security-webartifactId>
        dependency>
        
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>javax.servlet-apiartifactId>
            <scope>providedscope>
        dependency>
    dependencies>

二、yml文件配置

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/flowable?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=CTT
    username: root
    password: root
  security:
    filter:
      dispatcher-types: REQUEST,FORWARD,ASYNC
flowable:
  #关闭定时任务JOB
  async-executor-activate: false
  common:
    app:
      idm-url: http://localhost:8080/expense/
  idm:
    app:
      admin:
        user-id: admin
        password: test
        first-name: admin
        last-name: admin
  rest:
    app:
      authentication-mode: verify-privilege
  modeler:
    app:
      rest-enabled: true
  database-schema-update: false
mybatis:
  mapper-locations: classpath:/META-INF/modeler-mybatis-mappings/*.xml
  config-location: classpath:/META-INF/mybatis-config.xml
  configuration-properties:
    prefix:
    blobType: BLOB
    boolValue: TRUE
server:
  servlet:
    context-path: /expense

三、mybatis配置

resources/META-INF/mybatis-config.xml



<configuration>
	
	<settings>
		
		<setting name="cacheEnabled" value="false" />
		
		<setting name="lazyLoadingEnabled" value="false" />
		<setting name="multipleResultSetsEnabled" value="true" />
		<setting name="useColumnLabel" value="true" />
		<setting name="defaultStatementTimeout" value="25000" />
		<setting name="useGeneratedKeys" value="true" />
		<setting name="defaultExecutorType" value="REUSE" />
		<setting name="callSettersOnNulls" value="true" />
	settings>
configuration>

三、两个配置类

AppDispatcherServletConfiguration

@Configuration
@ComponentScan(value = {
        "org.flowable.ui.idm.rest.app",
        "org.flowable.ui.common.rest.exception",
        "org.flowable.ui.modeler.rest.app",
        "org.flowable.ui.common.rest"},
        excludeFilters = {
                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = RemoteAccountResource.class),
                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = StencilSetResource.class),
                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = EditorUsersResource.class),
                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = EditorGroupsResource.class)
        })
@EnableAsync
public class AppDispatcherServletConfiguration implements WebMvcRegistrations {

    private static final Logger LOGGER = LoggerFactory.getLogger(AppDispatcherServletConfiguration.class);

    @Bean
    public SessionLocaleResolver localeResolver() {
        return new SessionLocaleResolver();
    }

    @Bean
    public LocaleChangeInterceptor localeChangeInterceptor() {
        LOGGER.debug("Configuring localeChangeInterceptor");
        LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
        localeChangeInterceptor.setParamName("language");
        return localeChangeInterceptor;
    }

    @Override
    public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
        LOGGER.debug("Creating requestMappingHandlerMapping");
        RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
        requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
        requestMappingHandlerMapping.setRemoveSemicolonContent(false);
        Object[] interceptors = {localeChangeInterceptor()};
        requestMappingHandlerMapping.setInterceptors(interceptors);
        return requestMappingHandlerMapping;
    }

}

ApplicationConfiguration

@Configuration
@EnableConfigurationProperties({FlowableIdmAppProperties.class, FlowableModelerAppProperties.class})
@ComponentScan(basePackages = {
        "org.flowable.ui.idm.conf",
        "org.flowable.ui.idm.security",
        "org.flowable.ui.idm.service",
        "org.flowable.ui.modeler.repository",
        "org.flowable.ui.modeler.service",
        "org.flowable.ui.common.filter",
        "org.flowable.ui.common.service",
        "org.flowable.ui.common.repository",
        "org.flowable.ui.common.security",
        "org.flowable.ui.common.tenant"}, excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = org.flowable.ui.idm.conf.ApplicationConfiguration.class)})
public class ApplicationConfiguration {


    @Bean
    public ServletRegistrationBean apiServlet(ApplicationContext applicationContext) {
        AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
        dispatcherServletConfiguration.setParent(applicationContext);
        dispatcherServletConfiguration.register(ApiDispatcherServletConfiguration.class);
        DispatcherServlet servlet = new DispatcherServlet(dispatcherServletConfiguration);
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, "/api/*");
        registrationBean.setName("Flowable IDM App API Servlet");
        registrationBean.setLoadOnStartup(1);
        registrationBean.setAsyncSupported(true);
        return registrationBean;
    }

四、SpringbootApplication配置

@Import({
        ApplicationConfiguration.class,
        AppDispatcherServletConfiguration.class
})
@EnableTransactionManagement
@SpringBootApplication

至此,项目已基本配置完毕,可正常启动

注意:

application.yml 中flowable.database-schema-update配置:

true:数据库升级

false:检验版本

create-drop:

drop-create:

值为true时报错可改为false,只校验版本
SpringBoot集成Flowable UI_第1张图片

当校验版本出现如下异常时

SpringBoot集成Flowable UI_第2张图片
将这两张表中的全部版本信息改为异常中需要的版本信息

SpringBoot集成Flowable UI_第3张图片

SpringBoot集成Flowable UI_第4张图片

五、启动结果:

SpringBoot集成Flowable UI_第5张图片

六、前端文件

问题:

此时项目已经启动,但是我们按照war包形式访问项目时,会出现如下问题:

SpringBoot集成Flowable UI_第6张图片

是因为maven依赖并没有引入相关的静态资源文件

解决:

资源文件

将war包下里\WEB-INF\classes\static路径资源文件拷贝至springboot项目制resources下对应的文件夹内(如下规则):

SpringBoot集成Flowable UI_第7张图片

将以下两个文件放入resources内(流程节点)

SpringBoot集成Flowable UI_第8张图片

配置
@Configuration
public class MyWebMvcConfigurerAdapter implements WebMvcConfigurer {

    //静态资源配置
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/p/**")
                .addResourceLocations("classpath:/templates/page/");
        registry.addResourceHandler("/a/**")
                .addResourceLocations("classpath:/templates/assets/");
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/idm/**")
                .addResourceLocations("classpath:/idm/");
    }

    //跨域配置
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedMethods("*")
                .allowedOrigins("*")
                .allowedHeaders("*")
                .allowCredentials(true);
    }

    private CorsConfiguration buildConfig() {
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedOrigin("*");
        corsConfiguration.setAllowCredentials(true);
        corsConfiguration.addAllowedHeader("*");
        corsConfiguration.addAllowedMethod("*");

        return corsConfiguration;
    }


    /**
     * 跨域过滤器
     *
     * @return
     */
    @Bean
    public CorsFilter corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        source.registerCorsConfiguration("/**", buildConfig()); 
        return new CorsFilter(source);
    }
}

七、结果

http://localhost:8080/expense/idm/index.html

SpringBoot集成Flowable UI_第9张图片

账号:admin 密码:test

SpringBoot集成Flowable UI_第10张图片

http://localhost:8080/expense/

SpringBoot集成Flowable UI_第11张图片

SpringBoot集成Flowable UI_第12张图片

参考文档:

https://blog.csdn.net/puhaiyang/article/details/79845248

https://gitee.com/heiyueGit/springboot-flowable

你可能感兴趣的:(flowable,java,工具,java,flowable,spring,boot,工作流)