MySQL : 8.0 +
activiti : 6.0.0
下面是建表的代码:
@Test
public void createTable1() {
// 引擎配置
ProcessEngineConfiguration pec = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
pec.setJdbcDriver("com.mysql.cj.jdbc.Driver");
pec.setJdbcUrl("jdbc:mysql://localhost:3306/xf_test?characterEncoding=UTF-8&serverTimezone=UTC&useUnicode=true&useSSL=false");
pec.setJdbcUsername("root");
pec.setJdbcPassword("root");
/*
* false 不能自动创建表
* create-drop 先删除表再创建表
* true 自动创建和更新表
*/
pec.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
// 获取流程引擎对象
ProcessEngine processEngine = pec.buildProcessEngine();
}
报错:Caused by: java.sql.SQLSyntaxErrorException: Table 'xf_test.act_ge_property' doesn't exist
解决方法:
加上:nullCatalogMeansCurrent=true (注意: MySQL 8.0 + 版本需要加,之前的版本应该没问题)
含义:nullCatalogMeansCurrent为false时,会扫描当前连接的所有数据库,只要你此连接的其他数据库有activiti的这些表,就会 报错。 为 true 时,仅扫描当前指定的数据库
pec.setJdbcUrl("jdbc:mysql://localhost:3306/xf_test?characterEncoding=UTF-8&nullCatalogMeansCurrent=true&serverTimezone=UTC&useUnicode=true&useSSL=false")
本文介绍在使用Activiti 6.0.0与MySQL 8.0+版本进行数据库表创建时遇到的问题及解决方法。当尝试创建表时,由于MySQL扫描所有数据库导致错误。通过设置参数nullCatalogMeansCurrent=true,限制扫描范围至当前数据库,成功避免冲突。
9122

被折叠的 条评论
为什么被折叠?



