一:思路

  1. https://github.com/flowable/flowable-engine/releases/tag/flowable-6.6.0 下载Source code(zip)
  2. 使用IDEA打开flowable-engine-flowable-6.6.0/modules/flowable-ui 这个maven工程,打开之后会下载依赖,需要等依赖下载完成。
  3. 运行 flowable-ui-app/src/main/java/org/flowable/ui/application/FlowableUiApplication.java 启动Web服务。

四:SpringBoot集成Flowable UI_maven


四:SpringBoot集成Flowable UI_spring_02


因为flowable-ui下面只有flowable-ui-app是Web工程,其它都是jar工程,所以我们要想引入Flowable UI 只需要将这些jar引入到自己的SpringBoot工程即可。


二:方式一

  • 新建一个SpringBoot 工程,不需要添加任何依赖。
  • pom.xml 修改parent 为flowable-ui-parent
  • pom.xml 修改version值为flowable-ui的值
  • 将flowable-ui-app下的pom.xml中的依赖全部粘贴过来,并新增mysql-connector-java,注意数据库驱动不要加版本号。
  • pom.xml中的build增加resouce
  • 将spring-ui-app resources下的META-INF和flowable-default.properties 粘贴到自己项目来,注释掉原来的spring.datasource.url配置的h2, 打开MySQL对应的spring.datasource.相关的四个配置并修改对应的值。注释掉server.port,在自己的application.properties中去定义。
  • 将spring-ui-app下的org.flowable.ui.application全部复制到自己项目,包括完整的包名。
  • 去掉FlowableUiApplication类中的main方法,将@SpringBootApplication注解改为@Configuration
  • 手动为自己main方法所在的类增加组件扫码,组件扫码包含自己的包路径和flowable的包路径。@ComponentScan(basePackages = {“org.flowable.ui.application”, “com.example.springbootflowableui2”})

四:SpringBoot集成Flowable UI_spring_03

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.flowable</groupId>
        <artifactId>flowable-ui-parent</artifactId>
        <version>6.6.0</version>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>springboot-flowableui2</artifactId>
    <version>6.6.0</version>
    <name>springboot-flowableui2</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-task</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-admin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-idm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-modeler</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-properties-migrator</artifactId>
        </dependency>

        <!-- DATABASE -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.javacrumbs.json-unit</groupId>
            <artifactId>json-unit-assertj</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- LDAP dependencies needed for testing purposes -->
        <dependency>
            <groupId>org.springframework.ldap</groupId>
            <artifactId>spring-ldap-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.unboundid</groupId>
            <artifactId>unboundid-ldapsdk</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
    </dependencies>

    <build>
        <finalName>springboot-flowableui</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <builder>paketobuildpacks/builder-jammy-base:latest</builder>
                    </image>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

四:SpringBoot集成Flowable UI_xml_04

可以在集成的flowable-ui种创建流程、创建应用、发布应用、启动流程、审批流程等 这些数据都会落在MySQL数据库中。

四:SpringBoot集成Flowable UI_xml_05


三:方式二

方式一parent需要是flowable-ui-parent,一般我们的项目的parent是spring-boot-starter-parent或者自定义的parent,依赖flowable-ui-parent不好。
方式一要把FlowableUiApplication、SpringbootFlowableuiApplication放到org.flowable.ui.application下,还要增加@ComponentScan,方式二要把这两类直接放到自己项目包下,不再使用组件扫码。

四:SpringBoot集成Flowable UI_maven_06

  • pom.xml 直接引入带版本的flowable-ui对应依赖。
  • FlowableUiApplication、SpringbootFlowableuiApplication 直接粘贴到自己项目包下,
  • FlowableUiAppEventRegistryCondition增加@Component,
  • application.properties 增加配置 spring.main.allow-bean-definition-overriding=true
  • flowable-default.properties 和方式一的一样保持不变。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.11</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>springboot-flowableui</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-flowableui</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
        <flowable.version>6.6.0</flowable.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-task</artifactId>
            <version>${flowable.version}</version>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-admin</artifactId>
            <version>${flowable.version}</version>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-idm</artifactId>
            <version>${flowable.version}</version>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-ui-modeler</artifactId>
            <version>${flowable.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-properties-migrator</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.19</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <builder>paketobuildpacks/builder-jammy-base:latest</builder>
                    </image>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

四:SpringBoot集成Flowable UI_xml_07