camunda源代码编译运行(二):构建并运行camunda源代码工程

接上一篇文章:camunda源代码编译运行(一):下载编译camunda源代码

Camunda 7.19源代码一共有178个maven工程和1个angular前端工程,这么多工程中包括了大量的QA测试包、JDK不同版本适配(比如:Java EE和Jakarta EE)、多种中间件部署包(比如:Tomcat、Jboss、wildfly)、spring和springboot集成适配包等,我们仅仅需要把Camunda的流程引擎包和REST服务包的源代码拿来使用,下面通过IDEA开发工具,从代码层面整合Camunda的流程引擎源代码。

3.1、Camunda包结构分析

Camunda 7.19源代码一共有178个maven工程和1个angular前端工程,他们之间有什么样的依赖和引用关系,我们首先要分析清楚,然后才能把流程引擎和resf服务包的源代码拷贝过来使用。

下面我们就分析camunda-bpm-platform-7.19.0源代码中pom工程的引用和依赖关系。

首先,打开camunda-bpm-platform-7.19.0\engine工程的pom.xml,发现该工程继承了父工程camunda-database-settings。

打开父工程camunda-bpm-platform-7.19.0\database的pom.xml,发现它又继承了父工程camunda-parent。

打开父工程camunda-bpm-platform-7.19.0\parent的pom.xml,发现它又继承了父工程camunda-root。

打开父工程camunda-bpm-platform-7.19.0根目录下的pom.xml,发现它又继承了父工程camunda-bpm-release-parent,该工程没有源代码,就是camunda官方定义的发布版本的顶级工程了,是通过mvn依赖动态下载的。

至此,我们从camunda流程引擎内核包入手分析,找到了相关maven工程父子继承关系,即engine(BPMN流程引擎核心工程)—》database(多种数据库配置工程)—》parent(第三方Jar配置工程)—》root(camunda源代码聚合工程)。

有了以上分析,下面我们在自己的笔记本电脑上新建Java工程,把camunda核心源代码拷贝进来编译通过,最后通过springboot方式,把camunda源代码运行起来。

3.2、新建maven聚合工程

新建pom父工程,命名为camunda7-source-dev,version设置为7.19-SNAPSHOT,注意packaging的值为pom,该工程为聚合项目。

该工程的目的就是多个maven工程聚合,也可以根据需要配置一些manve的全局设置,比如仓库地址。

Pom.xml源文件如下:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.yuncheng</groupId>
    <artifactId>camunda7-source-dev</artifactId>
    <version>7.19-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
<!--        <module>camunda-engine</module>-->
<!--        <module>camunda-engine-rest</module>-->
<!--        <module>camunda-boot</module>-->
    </modules>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

</project>

3.3、新建maven父工程

通过以上分析camunda工程结构,发现camunda-engine流程引擎依赖了camunda-parent工程,而camunda-parent工程里定义了流程引擎需要的第三方Jar。这里我们也参考camunda-parent工程,新建一个自己的parent工程。

在刚才建的聚合工程camunda7-source-dev下,新建一个camunda-parent子工程。

我们需要把camunda-bpm-platform-7.19.0\parent\pom.xml文件内容拷贝过来,最后的pom.xml源文件如下:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yuncheng</groupId>
        <artifactId>camunda7-source-dev</artifactId>
        <version>7.19-SNAPSHOT</version>
    </parent>
    <packaging>pom</packaging>

    <artifactId>camunda-parent</artifactId>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <license.includeTransitiveDependencies>false</license.includeTransitiveDependencies>
        <!-- These properties are used in both the BOM as well as camunda-parent and subprojects -->
        <version.camunda>7.19.0</version.camunda>
        <version.mybatis>3.5.6</version.mybatis>
        <version.joda-time>2.1</version.joda-time>
        <version.uuid-generator>3.2.0</version.uuid-generator>
        <version.camunda.commons>1.12.0</version.camunda.commons>
        <version.camunda.connect>1.5.6</version.camunda.connect>
        <version.camunda.spin>1.19.0</version.camunda.spin>
        <version.camunda.template-engines>2.1.0</version.camunda.template-engines>
        <version.camunda.ee.xslt-plugin>1.1.0</version.camunda.ee.xslt-plugin>
        <version.feel-scala>1.15.3</version.feel-scala>
        <plugin.version.javadoc>3.0.1</plugin.version.javadoc>

        <!-- database driver versions -->
        <version.h2>2.1.214</version.h2>
        <version.h2-v1>1.4.190</version.h2-v1><!-- used for instance migration qa -->
        <version.oracle-12>12.1.0.2</version.oracle-12>
        <version.oracle-19>19.3.0.0</version.oracle-19>
        <version.oracle>${version.oracle-12}</version.oracle>
        <version.mariadb>1.7.6</version.mariadb>
        <version.mariadb-v1>1.1.8</version.mariadb-v1>
        <version.mysql>8.0.32</version.mysql>
        <version.sqlserver>8.4.1.jre8</version.sqlserver>
        <version.db2-11.5>11.5.0.0</version.db2-11.5>
        <version.db2>${version.db2-11.5}</version.db2>
        <version.postgresql>42.5.4</version.postgresql>
        <version.liquibase>4.8.0</version.liquibase>

        <!-- CockroachDB is compatible with PostgreSQL 9.5,
        so a different version of the JDBC driver needs to be used -->
        <version.cockroachdb>42.2.9</version.cockroachdb>

        <!-- needed for sql script and backward compatibility checks -->
        <camunda.version.old>7.18.0</camunda.version.old>

        <!-- Testcontainers JDBC URL parameters. By default, an empty string -->
        <database.tc.params />


        <version.quarkus>2.16.4.Final</version.quarkus>
        <version.spring.framework>5.3.22</version.spring.framework>
        <version.spring-boot>2.7.9</version.spring-boot>
        <version.cxf>3.0.3</version.cxf>
        <version.resteasy>3.15.3.Final</version.resteasy>
        <version.jersey2>2.34</version.jersey2>
        <!-- use minimum version of resteasy and jersey -->
        <version.jaxrs.api>2.0.1.Final</version.jaxrs.api>
        <version.groovy>2.4.21</version.groovy>
        <version.graal.js>21.1.0</version.graal.js>
        <version.icu.icu4j>68.2</version.icu.icu4j>
        <version.gson>2.8.9</version.gson>
        <version.openjpa>2.4.3</version.openjpa>
        <version.hibernate>5.6.5.Final</version.hibernate>
        <version.hikaricp>4.0.3</version.hikaricp>
        <version.jackson>2.14.1</version.jackson>
        <version.xml.bind-api>2.3.3</version.xml.bind-api>
        <version.xml.jaxb-impl>2.3.6</version.xml.jaxb-impl>
        <version.snakeyaml>1.33</version.snakeyaml>

        <version.slf4j>1.7.26</version.slf4j>
        <version.logback>1.2.11</version.logback>
        <version.junit>4.13.1</version.junit>
        <version.assertj>2.9.1</version.assertj>
        <version.mockito>4.3.1</version.mockito>
        <version.wiremock>2.27.2</version.wiremock>
        <version.wiremock-jre8>2.27.2</version.wiremock-jre8>
        <version.testcontainers>1.16.0</version.testcontainers>

        <version.commonj>1.1.0</version.commonj>
        <version.bouncycastle>1.47</version.bouncycastle>

        <!-- application servers -->
        <version.wildfly>27.0.1.Final</version.wildfly>
        <version.wildfly.core>19.0.1.Final</version.wildfly.core>
        <version.wildfly26>26.0.1.Final</version.wildfly26>
        <version.wildfly26.core>18.0.4.Final</version.wildfly26.core>

        <version.tomcat>9.0.72</version.tomcat>

        <version.arquillian>1.1.10.Final</version.arquillian>
        <version.shrinkwrap.resolvers>2.2.2</version.shrinkwrap.resolvers>
        <version.selenium>4.1.4</version.selenium>
        <version.freemarker>2.3.31</version.freemarker>

        <version.jboss-javaee-spec>3.0.2.Final</version.jboss-javaee-spec>
        <version.jakarta-ee-spec>10.0.0</version.jakarta-ee-spec>
    </properties>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${version.h2}</version>
            </dependency>
            <dependency>
                <groupId>com.oracle.jdbc</groupId>
                <artifactId>ojdbc7</artifactId>
                <version>${version.oracle}</version>
            </dependency>
            <dependency>
                <groupId>com.oracle.ojdbc</groupId>
                <artifactId>ojdbc8</artifactId>
                <version>${version.oracle}</version>
            </dependency>
            <dependency>
                <groupId>org.mariadb.jdbc</groupId>
                <artifactId>mariadb-java-client</artifactId>
                <version>${version.mariadb}</version>
            </dependency>
            <dependency>
                <groupId>com.mysql</groupId>
                <artifactId>mysql-connector-j</artifactId>
                <version>${version.mysql}</version>
            </dependency>
            <dependency>
                <groupId>com.microsoft.sqlserver</groupId>
                <artifactId>mssql-jdbc</artifactId>
                <version>${version.sqlserver}</version>
            </dependency>
            <dependency>
                <groupId>org.postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <version>${version.postgresql}</version>
            </dependency>
            <dependency>
                <groupId>com.ibm.db2</groupId>
                <artifactId>jcc</artifactId>
                <version>${version.db2}</version>
            </dependency>

            <dependency>
                <groupId>org.camunda.bpm</groupId>
                <artifactId>camunda-bom</artifactId>
                <version>${version.camunda}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <!-- test plugins -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.2</version>
                    <configuration>
                        <runOrder>hourly</runOrder>
                        <systemPropertyVariables>
                            <myWorkingDir>${project.build.directory}</myWorkingDir>
                        </systemPropertyVariables>
                        <argLine>-Xmx968m -Duser.language=en -Duser.region=US -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${project.build.directory}/heap_dump.hprof</argLine>
                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.16</version>
                    <configuration>
                        <argLine>-Xmx968m</argLine>
                        <runOrder>hourly</runOrder>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!-- code plugins -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.8</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.6</version>
                </plugin>

                <!-- artifact plugins -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <configuration>
                        <createSourcesJar>true</createSourcesJar>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.8</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.9.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven3-plugin</artifactId>
                    <version>1.10.5</version>
                </plugin>
                <plugin>
                    <groupId>net.kennychua</groupId>
                    <artifactId>maven-urlpoller-plugin</artifactId>
                    <version>1.0.3</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sql-maven-plugin</artifactId>
                    <version>1.5</version>
                    <configuration>
                        <keepFormat>true</keepFormat>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>clirr-maven-plugin</artifactId>
                    <version>2.8</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.4.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.3.2</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <configuration>
                        <failOnError>false</failOnError>
                        <additionalJOptions>
                            <additionalJOption>-Xdoclint:none</additionalJOption>
                            <additionalJOption>--ignore-source-errors</additionalJOption>
                        </additionalJOptions>
                        <doctitle>Camunda Platform Javadocs ${project.version}</doctitle>
                        <windowtitle>Camunda Platform Javadocs ${project.version}</windowtitle>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>

    <profiles>

    </profiles>

    <repositories>
        <repository>
            <id>JBoss public</id>
            <name>jboss</name>
            <url>https://repository.jboss.org/nexus/content/groups/public/</url>
        </repository>
        <!-- required for commonJ dependency -->
        <repository>
            <id>com.springsource.repository.bundles.external</id>
            <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
            <url>https://repo.spring.io/plugins-release</url>
        </repository>
    </repositories>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <organization>
        <name>camunda services GmbH</name>
        <url>http://www.camunda.com</url>
    </organization>

    <url>http://www.camunda.org</url>
</project>

3.4、新建流程引擎源码工程

在聚合工程camunda7-source-dev下,新建一个camunda-engine流程引擎子工程,需要把该工程的父工程配置为camunda-parent

我们需要把camunda-bpm-platform-7.19.0\engine\pom.xml文件内容拷贝过来,最后的pom.xml源文件如下:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yuncheng</groupId>
        <artifactId>camunda-parent</artifactId>
        <version>7.19-SNAPSHOT</version>
        <relativePath>../camunda-parent</relativePath>
    </parent>

    <artifactId>camunda-engine</artifactId>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <test.includes />
        <!-- without a special test profile we don't want to exclude anything, this expressions should never match -->
        <test.excludes>$.</test.excludes>
        <history.level>full</history.level>
        <mail.server.port>5025</mail.server.port>
        <authorizationCheckRevokes>auto</authorizationCheckRevokes>
        <jdbcBatchProcessing>true</jdbcBatchProcessing>

        <!-- We shade artifacts into the jar, so we need to generate a dependency BOM
        for the license book -->
        <skip-third-party-bom>false</skip-third-party-bom>

        <camunda.artifact>org.camunda.bpm</camunda.artifact>
        <version.camunda>7.19.0</version.camunda>
    </properties>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>org.camunda.bpm</groupId>
                <artifactId>camunda-core-internal-dependencies</artifactId>
                <version>${version.camunda}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>${version.spring.framework}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>jakarta.platform</groupId>
                <artifactId>jakarta.jakartaee-bom</artifactId>
                <version>${version.jakarta-ee-spec}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <dependencies>

        <!-- camunda dependencies -->

        <dependency>
            <groupId>org.camunda.bpm.model</groupId>
            <artifactId>camunda-bpmn-model</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.model</groupId>
            <artifactId>camunda-cmmn-model</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.dmn</groupId>
            <artifactId>camunda-engine-dmn</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>de.odysseus.juel</groupId>
                    <artifactId>juel-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>de.odysseus.juel</groupId>
                    <artifactId>juel-spi</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>de.odysseus.juel</groupId>
                    <artifactId>juel-impl</artifactId>
                </exclusion>
                <!-- these exclusions are needed when building with Maven >= 3.3
                  see CAM-11822 for details -->
                <exclusion>
                    <groupId>com.lihaoyi</groupId>
                    <artifactId>fastparse_2.13</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.lihaoyi</groupId>
                    <artifactId>sourcecode_2.13</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.lihaoyi</groupId>
                    <artifactId>geny_2.13</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.scala-lang</groupId>
                    <artifactId>scala-library</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.camunda.commons</groupId>
            <artifactId>camunda-commons-logging</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.commons</groupId>
            <artifactId>camunda-commons-typed-values</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
        </dependency>

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

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.connect</groupId>
            <artifactId>camunda-connect-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.connect</groupId>
            <artifactId>camunda-connect-connectors-all</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- provided dependencies -->

        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jta_1.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.uuid</groupId>
            <artifactId>java-uuid-generator</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-web-6.0</artifactId>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.transaction</groupId>
            <artifactId>jakarta.transaction-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.ejb</groupId>
            <artifactId>jakarta.ejb-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>catalina</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-vfs</artifactId>
            <version>3.1.0.Final</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-email</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- test dependencies  -->

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.subethamail</groupId>
            <artifactId>subethasmtp-wiser</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <!-- required for DiagramQueryTest -->
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.camunda.commons</groupId>
            <artifactId>camunda-commons-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-test-utils-testcontainers</artifactId>
            <version>${version.camunda}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-jsr223</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.python</groupId>
            <artifactId>jython</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-complete</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js-scriptengine</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-bpm-archunit</artifactId>
            <version>${version.camunda}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <!-- filter test configurations to inject properties -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>org/camunda/bpm/engine/product-info.properties</include>
                </includes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/camunda.cfg.xml</include>
                    <include>**/*camunda.cfg.xml</include>
                    <include>**/camunda.cfg.*.xml</include>
                    <include>testconfig.properties</include>
                    <include>**/testcontainers.properties</include>
                </includes>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <failIfNoTests>false</failIfNoTests>
                    <trimStackTrace>false</trimStackTrace>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <includes>
                        <include>%regex[.*(${test.includes}).*Test.*.class]</include>
                    </includes>
                    <excludes>
                        <exclude>**/*TestCase.java</exclude>
                        <exclude>%regex[.*(${test.excludes}).*Test.*.class]</exclude>
                    </excludes>
                    <dependenciesToScan>
                        <dependency>org.camunda.bpm:camunda-bpm-archunit</dependency>
                    </dependenciesToScan>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>cleanVersions</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <configuration>
                    <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
                    <createSourcesJar>true</createSourcesJar>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
                    <artifactSet>
                        <excludes>
                            <exclude>org.camunda.bpm.model:*</exclude>
                            <exclude>org.camunda.bpm.dmn:*</exclude>
                            <exclude>org.camunda.commons:*</exclude>
                            <exclude>org.camunda.connect:*</exclude>
                            <exclude>org.camunda.feel:*</exclude>

                            <exclude>org.springframework:*</exclude>
                            <exclude>org.slf4j:*</exclude>
                            <exclude>org.apache.commons:*</exclude>
                            <exclude>com.sun.mail:*</exclude>
                            <exclude>javax.activation:*</exclude>
                            <exclude>org.mybatis:mybatis:*</exclude>
                            <exclude>commons-logging:*</exclude>
                            <exclude>joda-time:*</exclude>
                        </excludes>
                    </artifactSet>
                    <relocations>
                        <relocation>
                            <pattern>com.google.gson</pattern>
                            <shadedPattern>camundajar.impl.com.google.gson</shadedPattern>
                        </relocation>
                    </relocations>
                    <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                    </transformers>
                    <shadeTestJar>true</shadeTestJar>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-upgrade-scripts-liquibase</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>

                                <!-- copy all upgrade scripts after 7.15 -->
                                <mkdir dir="target/classes/org/camunda/bpm/engine/db/liquibase/upgrade" />
                                <copy todir="target/classes/org/camunda/bpm/engine/db/liquibase/upgrade">
                                    <fileset dir="target/classes/org/camunda/bpm/engine/db/upgrade" excludes="*_6.*_*,*_7.0_*,*_7.1_*,*_7.2_*,*_7.3_*,*_7.4_*,*_7.5_*,*_7.6_*,*_7.7_*, *_7.8_*,*_7.9_*,*_7.10_*,*_7.11_*,*_7.12_*,*_7.13_*,*_7.14_*,*_7.15_*" />
                                </copy>

                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.felix</groupId>
                                        <artifactId>
                                            maven-bundle-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.1.0,)
                                        </versionRange>
                                        <goals>
                                            <goal>cleanVersions</goal>
                                            <goal>manifest</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>distro</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>h2-in-memory</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <database.url>jdbc:h2:mem:camunda;DB_CLOSE_DELAY=1000;LOCK_TIMEOUT=10000</database.url>
                <database.driver>org.h2.Driver</database.driver>
                <database.username>sa</database.username>
                <database.password />
                <hibernate.dialect>org.hibernate.dialect.H2Dialect</hibernate.dialect>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>sql-maven-plugin</artifactId>
                            <dependencies>
                                <dependency>
                                    <groupId>com.h2database</groupId>
                                    <artifactId>h2</artifactId>
                                    <version>${version.h2}</version>
                                </dependency>
                            </dependencies>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

    </profiles>

</project>

到这里,你可以通过IDEA的maven工具先执行mvn clean install命令,把相关依赖包下载下来,同时验证一下这几个maven工程是否能编译通过。

接下来,拷贝camunda-bpm-platform-7.19.0\engine引擎包下的源代码到自己刚刚新建的camunda-engine工程下,再执行mvn clean install命令进行编译打包,检查是否可以通过。由于camunda-engine源代码中有大量的测试用例,编译比较耗时,这里通过mvn clean install -DskipTests=true命令跳过测试用例执行。

3.5、新建REST服务源码工程

在聚合工程camunda7-source-dev下,新建一个camunda-engine-rest流程引擎rest服务子工程,需要把该工程的父工程配置为camunda-parent

我们需要把camunda-bpm-platform-7.19.0\engine-rest\engine-rest\pom.xml文件内容拷贝过来,最后的pom.xml源文件如下:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yuncheng</groupId>
        <artifactId>camunda-parent</artifactId>
        <version>7.19-SNAPSHOT</version>
        <relativePath>../camunda-parent</relativePath>
    </parent>

    <artifactId>camunda-engine-rest</artifactId>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.rest-assured>4.5.0</version.rest-assured>
        <!-- override groovy version with the one used by rest-assured -->
        <version.groovy>3.0.9</version.groovy>
        <version.apache.httpcore>4.4.5</version.apache.httpcore>
        <version.commons-codec>1.15</version.commons-codec>
        <!-- pin tomcat version for engine-rest -->
        <version.tomcat>7.0.50</version.tomcat>
        <rest.http.port>38080</rest.http.port>
        <javax.activation.version>1.1.1</javax.activation.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${version.spring-boot}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-bom</artifactId>
                <version>${version.groovy}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.camunda.bpm</groupId>
                <artifactId>camunda-core-internal-dependencies</artifactId>
                <version>${version.camunda}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>${version.xml.jaxb-impl}</version>
            </dependency>
            <dependency>
                <groupId>io.rest-assured</groupId>
                <artifactId>rest-assured</artifactId>
                <version>${version.rest-assured}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson</groupId>
                <artifactId>jackson-bom</artifactId>
                <version>${version.jackson}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>${version.apache.httpcore}</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>${version.commons-codec}</version>
            </dependency>
        </dependencies>

    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>commons-io</groupId>
                    <artifactId>commons-io</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- override managed version from commons-fileupload -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>jakarta.activation</groupId>
                    <artifactId>jakarta.activation-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jakarta.xml.bind</groupId>
                    <artifactId>jakarta.xml.bind-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>

        <!-- provided deps -->
        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.yuncheng</groupId>
            <artifactId>camunda-engine</artifactId>
            <version>7.19-SNAPSHOT</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-jcl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.camunda.commons</groupId>
            <artifactId>camunda-commons-logging</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>${javax.activation.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <version>${version.tomcat}</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${version.spring.framework}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-jcl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Tomcat for resteasy and wink -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.camunda.commons</groupId>
            <artifactId>camunda-commons-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
            <version>${version.tomcat}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-logging-juli</artifactId>
            <version>${version.tomcat}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <restEasyVersion>${version.resteasy}</restEasyVersion>
                    </systemPropertyVariables>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>distro</id>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.spec.javax.ws.rs</groupId>
                    <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jersey2</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>javax.ws.rs-api</artifactId>
                    <version>2.0.1</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jersey.containers</groupId>
                    <artifactId>jersey-container-grizzly2-http</artifactId>
                    <version>${version.jersey2}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jersey.containers</groupId>
                    <artifactId>jersey-container-servlet</artifactId>
                    <version>${version.jersey2}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jersey.inject</groupId>
                    <artifactId>jersey-hk2</artifactId>
                    <version>${version.jersey2}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>**/rest/standalone/**</exclude>
                            </excludes>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                        </configuration>
                        <executions>
                            <execution>
                                <id>encoding-test</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <argLine>-Dfile.encoding=ISO-8859-1</argLine>
                                    <includes>
                                        <include>**/ProcessDefinitionRestServiceInteractionTest.java</include>
                                        <include>**/TaskRestServiceInteractionTest.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-test-source</id>
                                <phase>generate-test-sources</phase>
                                <goals>
                                    <goal>add-test-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/test/java-jersey2</source>
                                    </sources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>add-test-resource</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>add-test-resource</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>src/test/resources-jersey2</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>
</project>

接下来,拷贝camunda-bpm-platform-7.19.0\engine-rest\engine-rest工程下的源代码到自己刚刚新建的工程里,再执行mvn clean install命令进行编译打包,检查是否可以通过。

3.6、新建Springboot启动工程

以上4个步骤新建了4个Java maven工程,如果这4个工程均可编译通过,说明camunda源代码迁移这一步骤是没有问题的,接下来就是需要把camunda流程引擎基于源代码方式运行起来。

在聚合工程camunda7-source-dev下,新建一个名称为camunda-boot 的工程,即流程引擎的springboot启动工程。

在该工程下把需要把刚刚新建的流程引擎工程camunda-engine和流程引擎服务工程camunda-engine-rest引入进来,确保它是基于源代码运行的,最后的pom.xml源文件如下:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yuncheng</groupId>
        <artifactId>camunda-parent</artifactId>
        <version>7.19-SNAPSHOT</version>
        <relativePath>../camunda-parent</relativePath>
    </parent>

    <artifactId>camunda-boot</artifactId>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!--定义使用camunda的版本-->
        <version.camunda>7.19.0</version.camunda>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${version.spring-boot}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

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

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <!--mysql-->
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
        </dependency>

        <dependency>
            <groupId>com.yuncheng</groupId>
            <artifactId>camunda-engine</artifactId>
            <version>7.19-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.yuncheng</groupId>
            <artifactId>camunda-engine-rest</artifactId>
            <version>7.19-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
            <version>${version.camunda}</version>
            <!--排除官方引用jar包,用自己工程里的源代码包-->
            <exclusions>
                <exclusion>
                    <groupId>org.camunda.bpm</groupId>
                    <artifactId>camunda-engine</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.camunda.bpm</groupId>
                    <artifactId>camunda-engine-rest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter</artifactId>
            <version>${version.camunda}</version>
            <!--排除官方引用jar包,用自己工程里的源代码包-->
            <exclusions>
                <exclusion>
                    <groupId>org.camunda.bpm</groupId>
                    <artifactId>camunda-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>

</project>

接下来,新建一个SpringBootApplication启动类:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

@SpringBootApplication
public class Camunda7Application {

    private static final Logger log = LoggerFactory.getLogger(Camunda7Application.class);

    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(Camunda7Application.class, args);
        Environment env = application.getEnvironment();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (path == null || "".equals(path)) {
            path = "/";
        }
        log.info("\n----------------------------------------------------------\n" +
                "\tApplication is running!\n" +
                "\tPort:\t" + port + "\n" +
                "\tPath:\t" + path + "\n" +
                "----------------------------------------------------------");
    }
}

最后,新建一个springboot启动的application.yaml配置文件,我这里用的是druid连接池,H2数据库,你也可以根据需要切换成mysql数据库

server:
  port: 8080
spring:
  datasource:
#    url: jdbc:mysql://127.0.0.1:3306/camunda719?characterEncoding=UTF-8&useUnicode=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
#    username: root
#    password: root
#    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:h2:mem:camunda;DB_CLOSE_DELAY=1000;LOCK_TIMEOUT=10000
    username: sa
    password:
    driver-class-name: org.h2.Driver
camunda:
  bpm:
    database:
      type: h2 #可改成 mysql
      schema-update: true
    auto-deployment-enabled: false # 自动部署 resources 下的 bpmn文件
    admin-user:
      id: demo
      password: demo

以上这些完成后,启动springboot工程即可。

至此,我们完成了基于camunda源代码编译和运行流程引擎。

接下来通过rest服务接口验证camunda流程引擎的功能。

camunda源代码编译运行(三):验证camunda API接口功能

  • 31
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Camunda 中,您可以通过以下步骤查看数据源配置: 1. 打开 `camunda.cfg.xml` 配置文件。 2. 查找以下内容: ```xml <jdbc:embedded-database id="dataSource" type="H2"> <jdbc:script location="classpath:org/camunda/bpm/engine/db/create/activiti.h2.create.engine.sql" /> <jdbc:script location="classpath:org/camunda/bpm/engine/db/create/activiti.h2.create.history.sql" /> <jdbc:script location="classpath:org/camunda/bpm/engine/db/create/activiti.h2.create.identity.sql" /> <jdbc:script location="classpath:org/camunda/bpm/engine/db/create/activiti.h2.create.case.engine.sql" /> <jdbc:script location="classpath:org/camunda/bpm/engine/db/create/activiti.h2.create.case.history.sql" /> <jdbc:script location="classpath:org/camunda/bpm/engine/db/create/activiti.h2.create.decision.engine.sql" /> <jdbc:script location="classpath:org/camunda/bpm/engine/db/create/activiti.h2.create.decision.history.sql" /> </jdbc:embedded-database> ``` 以上是使用嵌入式 H2 数据库的示例。如果您使用的是其他类型的数据库,例如 MySQL 或 Oracle,这部分的内容将会有所不同。 3. 查看 `jdbc:embedded-database` 元素中的 `id` 属性值。该属性值指定了数据源的 ID,例如上述示例中的 `dataSource`。 4. 查看 `jdbc:embedded-database` 元素中的 `type` 属性值。该属性值指定了使用的数据库类型,例如上述示例中的 `H2`。 5. 查看 `jdbc:embedded-database` 元素中的 `jdbc:script` 元素。该元素指定了在启动时要执行的 SQL 脚本,用于创建表和其他数据库对象。 6. 如果需要进一步了解数据源配置,可以查看在 Camunda 引擎的启动配置中指定的数据源信息。例如,在 Java 代码中,可以使用 `ProcessEngineConfiguration` 对象的 `getDataSource()` 方法获取数据源对象,并查看其属性和配置。 ```java ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration(); DataSource dataSource = configuration.getDataSource(); // 查看数据源属性和配置 ``` 上述步骤可以帮助您查看 Camunda 数据源的配置信息,从而更好地了解其工作原理和使用方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大龄码农有梦想

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值