activiti6 創建表失敗

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")

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章