SpringBoot+flowable-ui集成实战
前⾔
公司最近想要使⽤flowable作为我们⼯作流引擎,主要⽤于各类流程审批上。在⽹上搜索到了很多有参考意义的⽂章,但有些实现细节还需要⾃⼰去摸索。本⽂的实战包括:
1. 在项⽬中引⼊flowable的包可以使⽤flowable的api;
2. 将flowable-ui集成到⾃⼰项⽬⾥;
3. 如何使⽤flowable-ui创建的流程模型(我们⽤的是bpmn模型,所以后⾯的提到的流程都是指bpmn);
4. 集成公司的⽤户认证体系;
5. ⾃动分配
flowable集成
flowable的集成有两部分:flowable-api与flowable-ui。flowable-api主要管创建好流程后怎么使⽤,flowa
ble-ui就是通过页⾯去编排我们的流程。
jar包引⼊
这⾥的是较新的版本6.7.0。因为⾃⾝的框架⽤的是springboot,所以需要引⼊⼀个starter。引⼊的包⾥有flowable-ui-xxx是flowable-ui需要的包;其他是我们使⽤flowable-api需要的包。
<properties>
<flowable.version>6.7.0</flowable.version>
</properties>
<dependencies>springboot架构图
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-idm-spring-configurator</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-json-converter</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-rest</artifactId>
<version>${flowable.version}</version>
<exclusions>
<exclusion>
<groupId>org.flowable</groupId>
<artifactId>flowable-json-converter</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-conf</artifactId>
<version>${flowable.version}</version>
<version>${flowable.version}</version>
<exclusions>
<exclusion>
<groupId>org.flowable</groupId>
<artifactId>flowable-json-converter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-idm-conf</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-idm-rest</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-form-engine</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-form-spring</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-form-engine-configurator</artifactId> <version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-form-spring-configurator</artifactId> <version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-app-engine</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.3.5</version>
<exclusions>
<exclusion>
<groupId&l.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
配置
flowablemon.app.idm-url = /idm
flowable.database-schema-update = true
flowable.process.definition-cache-limit = 1
# mybatis配置
mybatis.mapper-locations = classpath:/META-INF/modeler-mybatis-mappings/*.xml
Web配置
路由
@Configuration
@EnableConfigurationProperties({FlowableIdmAppProperties.class, FlowableModelerAppProperties.class})
@ComponentScan(basePackages = {
"org.flowable.f",
// "org.flowable.ui.idm.security",
"org.flowable.ui.idm.service",
"org.pository",
"org.deler.service",
// "org.flowable.uimon.filter",
"org.flowable.uimon.service",
"org.pository",
// "org.flowable.uimon.security",
"org.ant",
"org.flowable.form"
}, excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = org.flowable.f.ApplicationConfiguration.class) })
public class ApplicationConfiguration implements BeanPostProcessor {
@Bean
public ServletRegistrationBean apiServlet(ApplicationContext applicationContext) {
AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
dispatcherServletConfiguration.setParent(applicationContext);
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;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
// 这⾥与⽤户鉴权相关这⾥先省略
...
}
}
i18n
@ComponentScan(basePackages = {
"org.flowable.st.app",
"org.st.exception",
"org.st.app",
"org.st"
}, 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)
})
@Slf4j
public class AppDispatcherServletConfiguration implements WebMvcRegistrations {
@Bean
public SessionLocaleResolver localeResolver() {
return new SessionLocaleResolver();
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
log.debug("Configuring localeChangeInterceptor");
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
localeChangeInterceptor.setParamName("language");
return localeChangeInterceptor;
}
@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
log.debug("Creating requestMappingHandlerMapping");
RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping(); requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
requestMappingHandlerMapping.setRemoveSemicolonContent(false);
Object[] interceptors = {localeChangeInterceptor()};
requestMappingHandlerMapping.setInterceptors(interceptors);
return requestMappingHandlerMapping;
}
}
页⾯集成
路由集成后,我们需要将资源⽂件放到我们的resource⽬录下。⾸先需要将路由跟资源路径绑定:
@Configuration
public class WebMvcConfigurerAdapter implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/modeler/**")
.addResourceLocations("classpath:/static/modeler/");
registry.addResourceHandler("/idm/**")
.addResourceLocations("classpath:/static/idm/");
}
}
然后从flowable-engine源码中将前端资源拷贝到⾃⼰的项⽬下:
1. 源码地址:github/flowable/flowable-engine
2. 进⼊modules/flowable-ui⽬录
3. 拷贝flowable-idm-frontend、flowable-modeler-frontend、flowable-task-frontend到⾃⼰的项⽬下,如下图:
数据库初始化
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论