最近项目要集成流程引擎,项目本身使用的是springboot,网上搜索铺天盖地的是Activiti和Flowable。两者区别大家自行百度。最后选择的是Flowable的最新版本6.3.1。
1、下载源码
Flowable在Github上的地址是https://github.com/flowable/flowable-engine,6.3.1版本地址是https://github.com/flowable/flowable-engine/tree/flowable-6.3.1。如果用git clone的话下来的是6.3.2-SNAPSHOT版本,这里推荐使用下载zip包的方式下载源码。
2、解压
将源码的zip包解压后方到指定的目录,修改目录名称为:flowable-engine。
3、打开源码
这里使用的是IDEA的开发环境,直接用IDEA打开flowable-engine目录。此时需要等待较长的时间让其自行解决Maven的依赖。
4、修改源码
4.1、修改工程中根pom文件。将第一个<modules>标签中的内容替换:(大概在第953行)
<modules>
<module>modules/flowable-bpmn-model</module>
<module>modules/flowable-process-validation</module>
<module>modules/flowable-image-generator</module>
<module>modules/flowable-bpmn-converter</module>
<module>modules/flowable-engine</module>
<module>modules/flowable-secure-javascript</module>
<module>modules/flowable-groovy-script-static-engine</module>
<module>modules/flowable-bpmn-layout</module>
<module>modules/flowable-json-converter</module>
<module>modules/flowable-spring-common</module>
<module>modules/flowable-engine-configurator</module>
<module>modules/flowable-spring-configurator</module>
<module>modules/flowable-app-engine-spring</module>
<module>modules/flowable-app-engine-rest</module>
<module>modules/flowable-dmn-model</module>
<module>modules/flowable-dmn-json-converter</module>
<module>modules/flowable-dmn-xml-converter</module>
<module>modules/flowable-dmn-engine</module>
<module>modules/flowable-dmn-engine-configurator</module>
<module>modules/flowable-dmn-spring</module>
<module>modules/flowable-dmn-spring-configurator</module>
<module>modules/flowable-dmn-rest</module>
<module>modules/flowable-dmn-api</module>
<module>modules/flowable-cmmn-api</module>
<module>modules/flowable-cmmn-model</module>
<module>modules/flowable-cmmn-converter</module>
<module>modules/flowable-cmmn-json-converter</module>
<module>modules/flowable-cmmn-engine</module>
<module>modules/flowable-cmmn-engine-configurator</module>
<module>modules/flowable-cmmn-spring</module>
<module>modules/flowable-cmmn-spring-configurator</module>
<module>modules/flowable-cmmn-rest</module>
<module>modules/flowable-form-model</module>
<module>modules/flowable-form-json-converter</module>
<module>modules/flowable-form-engine</module>
<module>modules/flowable-form-engine-configurator</module>
<module>modules/flowable-form-spring</module>
<module>modules/flowable-form-spring-configurator</module>
<module>modules/flowable-form-rest</module>
<module>modules/flowable-content-engine</module>
<module>modules/flowable-content-engine-configurator</module>
<module>modules/flowable-content-spring</module>
<module>modules/flowable-content-spring-configurator</module>
<module>modules/flowable-content-rest</module>
<module>modules/flowable-common-rest</module>
<module>modules/flowable-rest</module>
<module>modules/flowable-app-rest</module>
<module>modules/flowable-idm-engine-configurator</module>
<module>modules/flowable-idm-spring</module>
<module>modules/flowable-idm-spring-configurator</module>
<module>modules/flowable-idm-rest</module>
<module>modules/flowable-spring</module>
<module>modules/flowable5-engine</module>
<module>modules/flowable5-compatibility</module>
<module>modules/flowable5-spring</module>
<module>modules/flowable5-spring-compatibility</module>
<module>modules/flowable-spring-boot</module>
<module>modules/flowable-cxf</module>
<module>modules/flowable-mule</module>
<module>modules/flowable-http</module>
<module>modules/flowable-camel</module>
<module>modules/flowable-camel-cdi</module>
<module>modules/flowable-cdi</module>
<module>modules/flowable-osgi</module>
<module>modules/flowable-ldap</module>
<module>modules/flowable-ldap-configurator</module>
<module>modules/flowable-jmx</module>
<module>modules/flowable-jms-spring-executor</module>
<module>modules/flowable-ui-common</module>
<module>modules/flowable-ui-edge</module>
<module>modules/flowable-ui-idm</module>
<module>modules/flowable-ui-modeler</module>
<module>modules/flowable-ui-task</module>
<module>modules/flowable-ui-admin</module>
<module>tooling/archetypes/flowable-archetype-unittest</module>
</modules>
4.2、如果数据库想使用mysql,参考如下:其他数据库配置类似
根pom文件找到mysql的依赖,将其<scope>test</scope>这行注释掉。
分别找到flowable-ui-admin、flowable-ui-idm、flowable-ui-modeler、flowable-ui-task着四个module。分别修改它们下面的各个app子modules的pom、fowable-default.properties文件(其中flowable-ui-admin中还需要修改其resources目录下的application-dev.properties文件)
子pom文件:添加下图中的依赖,原来的h2保留或删除都可以,我的是保留了,没删。
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
fowable-default.properties文件:注释掉原来h2的驱动和url,修改数据库连接的用户名和密码。
#spring.datasource.url=jdbc:h2:tcp://localhost/flowableadmin
#spring.datasource.url=jdbc:h2:~/flowable-db/db;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9091;DB_CLOSE_DELAY=-1
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.1.146:3306/flowable?characterEncoding=UTF-8
#spring.datasource.driver-class-name=org.postgresql.Driver
#spring.datasource.url=jdbc:postgresql://localhost:5432/flowableadmin
#spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
#spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=flowableadmin
#spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
#spring.datasource.url=jdbc:oracle:thin:@localhost:1521:FLOWABLEADMIN
#spring.datasource.driver-class-name=com.ibm.db2.jcc.DB2Driver
#spring.datasource.url=jdbc:db2://localhost:50000/flowableadmin
spring.datasource.username=root
spring.datasource.password=12345
4.3、编译
![编译截图](https://i-blog.csdnimg.cn/blog_migrate/27972068a373da4562c264d662bb5208.png)
编译成功后分别启动idm、admin、modeler、task四个module。启动成功,浏览器地址栏输入:http://localhost:8888/flowable-modeler。弹出登录页面的用户名和密码分别是admin/test。
至此,源码编译完成。