【Activiti】從入門到放棄——建立工作流資料庫
阿新 • • 發佈:2018-12-07
1.導包
共48個
自取:https://download.csdn.net/download/qq_43097451/10817487
新增配置檔案 - activiti.cfg.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> <!--資料連線資訊 --> <property name="jdbcUrl" value="jdbc:mysql:///activiti?createDatabaseIfNotExist=true" /> <property name="jdbcDriver" value="com.mysql.jdbc.Driver" /> <property name="jdbcUsername" value="root" /> <property name="jdbcPassword" value="123456" /> <!-- 自動建表 --> <property name="databaseSchemaUpdate" value="true" /> </bean> </beans>
測試
方式一: 無需配置
// 硬編碼 @Test public void testConnect() throws Exception { // 根據doc文件 ctrl+f ProcessEngineConfiguration 不用配置檔案 // 配置資訊 ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration .createStandaloneProcessEngineConfiguration(); // jdbc 連線資訊 processEngineConfiguration.setJdbcUrl("jdbc:mysql:///activiti?createDatabaseIfNotExist=true"); processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver"); processEngineConfiguration.setJdbcUsername("root"); processEngineConfiguration.setJdbcPassword("123456"); // 自動建立表 processEngineConfiguration.setDatabaseSchemaUpdate("true"); // 服務核心物件 (一旦核心物件 它就會建立表結構) ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine(); System.out.println(processEngine); }
方式二:載入配置檔案 - activiti.cfg.xml
// 自定義配置檔案 // @Test public void testConnect2() throws Exception { // 載入配置類的物件 ProcessEngineConfiguration createProcessEngineConfigurationFromResource = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml"); // 核心物件 ProcessEngine buildProcessEngine = createProcessEngineConfigurationFromResource.buildProcessEngine(); System.out.println(buildProcessEngine); }