赞
踩
一、Flowable介绍及部署
二、SpringBoot集成Flowable UI
三、Flowable UI跳过权限验证
四、Flowable UI整合前后分离
<properties> <java.version>1.8</java.version> <flowable.version>6.4.0</flowable.version> <mybatis-spring-boot>1.3.1</mybatis-spring-boot> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--flowable工作流依赖--> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-spring-boot-starter-basic</artifactId> <version>${flowable.version}</version> </dependency> <!--mysql依赖--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> </dependency> <!-- Spring Boot Mybatis 依赖 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.0.31</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.46</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-ui-common</artifactId> <version>${flowable.version}</version> </dependency> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-ui-modeler-rest</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-ui-idm-rest</artifactId> <version>${flowable.version}</version> </dependency> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-ui-idm-conf</artifactId> <version>${flowable.version}</version> </dependency> <dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> <version>3.6.2</version> </dependency> <!--security --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-crypto</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> </dependency> <!-- Servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency> </dependencies>
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
resources/META-INF/mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 配置mybatis的一些参数 --> <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>
@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; } }
@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; }
@Import({
ApplicationConfiguration.class,
AppDispatcherServletConfiguration.class
})
@EnableTransactionManagement
@SpringBootApplication
至此,项目已基本配置完毕,可正常启动
application.yml 中flowable.database-schema-update配置:
true:数据库升级
false:检验版本
create-drop:
drop-create:
值为true时报错可改为false,只校验版本
当校验版本出现如下异常时
将这两张表中的全部版本信息改为异常中需要的版本信息
此时项目已经启动,但是我们按照war包形式访问项目时,会出现如下问题:
是因为maven依赖并没有引入相关的静态资源文件
将war包下里\WEB-INF\classes\static路径资源文件拷贝至springboot项目制resources下对应的文件夹内(如下规则):
将以下两个文件放入resources内(流程节点)
@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
账号:admin 密码:test
http://localhost:8080/expense/
参考文档:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。