通过上述操作,理论上可以不需要java代码编写,就可以完成工作流的集成,这也是后面计划进行的,动态流程+动态表单的一个工作计划。目标是通过activiti+mongodb,简化业务流程编码,减少复杂数据库设计工作。
Activiti6.0
官网下载:https://www.activiti.org/get-started
下载后,会在里面有3个war包,放到tomcat8的webapps里面,直接启动,会自动解压。解压后,关闭tomcat,进行mysql连接配置
tomcat、mysql和jdk下载安装
上一节,已经将下载的activiti的3个war包放到tomcat8的webapps下直接启动,会自动解压。解压后,关闭tomcat,进行mysql连接配置
Malformed database URL, failed to parse the main URL sections.
这个一般是数据库连接不对。这里把正确的数据库配置写下来。
activiti-admin:这个包,不要改任何东西,因为最终它是通过api跟activiti-app交互的,所以无需配置db,任何东西都不要改。
activiti-app: 修改路径在/opt/apache-tomcat-8.5.63-all/webapps/activiti-app/WEB-INF/classes/META-INF/activiti-app/activiti-app.properties
完整的配置信息如下:
#
# SECURITY
#
security.rememberme.key=testkey
#
# DATABASE
#
#datasource.driver=org.h2.Driver
#datasource.url=jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1
datasource.driver=com.mysql.jdbc.Driver
#datasource.driver=com.mysql.cj.jdbc.Driver
datasource.url=jdbc:mysql://172.18.102.152:3306/activiti6ui?useUnicode=true&useSSL=false&serverTimezone=UTC
datasource.username=root
datasource.password=example
#hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.dialect=org.hibernate.dialect.MySQLDialect
#hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
#hibernate.dialect=org.hibernate.dialect.SQLServerDialect
#hibernate.dialect=org.hibernate.dialect.DB2Dialect
#hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#
# EMAIL
#
#email.enabled=true
#email.host=localhost
#email.port=1025
#email.useCredentials=false
#email.username=
#email.password=
# The base url that will be used to create urls in emails.
#email.base.url=http://localhost:9999/activiti-app
#email.from.default=no-reply@activiti.alfresco.com
#email.from.default.name=Activiti
#email.feedback.default=activiti@alfresco.com
#
# ACTIVITI
#
activiti.process-definitions.cache.max=500
#
# DEFAULT ADMINISTRATOR ACCOUNT
#
admin.email=admin
admin.password=test
admin.lastname=Administrator
admin.group=Superusers
# The maximum file upload limit. Set to -1 to set to 'no limit'. Expressed in bytes
file.upload.max.size=104857600
# For development purposes, data folder is created inside the sources ./data folder
contentstorage.fs.rootFolder=data/
contentstorage.fs.createRoot=true
contentstorage.fs.depth=4
contentstorage.fs.blockSize=1024
Activiti-rest: 修改路径在/opt/apache-tomcat-8.5.63-all/webapps/activiti-rest/WEB-INF/classes/db.properties
完整的配置信息如下:
#db=h2
#jdbc.driver=org.h2.Driver
#jdbc.url=jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1
#jdbc.username=sa
#jdbc.password=
db=MySQL
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://172.18.102.152:3306/activiti6ui?useSSL=false&serverTimezone=UTC
jdbc.username=root
jdbc.password=example
使用mysql5.6.37
Index column size too large. The maximum column size is 767 bytes
这个是无解的,因为无法修改war包源码里面activiti建表语句(我没找到~),所以改不了。还是建议升级到mysql 5.7
mysql5.7默认是区分大小写的,要设置为不区分大小写。否则会报错找不到数据库表。使用命令show VARIABLES like 'lower%';
查看,需要lower_case_table_names
的值为1,正确结果如下:
我这里是使用的docker建的mysql容器,命令是:
// 创建容器(忽略大小写)
docker run --name mysq.db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d -v /home/mysql/:/var/lib/mysql mysql --lower_case_table_names=1
使用mysql8,这里验证,启动activiti-admin和activiti-app没问题,但是activiti-rest起不来,后台catalina.out看不到有意义的报错,放弃使用mysql8。
在activiti-app创建流程图的时候,保存带有中文的流程失败,后台报错如下。
SQLException: Incorrect string value: '\xE5\x8F\x91\xE8\xB5\xB7...'
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-aniiylmh-1663230068595)(/Users/kelvin/Library/Application Support/typora-user-images/image-20220915150151664.png)]
解决方案:数据库连接上,不要指定characterEncoding=utf-8
,指定了反而会报错。正确样例:
datasource.url=jdbc:mysql://172.18.102.152:3306/activiti6ui?useUnicode=true&useSSL=false&serverTimezone=UTC
activiti-admin
http://172.18.102.134:8080/activiti-admin
admin/admin
activiti-app
http://172.18.102.134:8080/activiti-app
admin/test
activiti-rest
访问一个get类型的查询接口:http://172.18.102.134:8080/activiti-rest/service/repository/deployments
账号密码:kermit/kermit