<dependency> <groupId>org.activiti</groupId> <artifactId>activiti-spring-boot-starter</artifactId> <version>7.1.0.M6</version> </dependency> 注入activiti 组件 初始化activiti 表 以下单元测试用例 用来初始化 activiti 表
@SpringBootTest
class ActivitiApplicationTests {
@Test
void contextLoads() {
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
processEngineConfiguration.buildProcessEngine();
}
}
activiti.cfg.xml 是在类目录下的 一个spring beans 配置文件
<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="dataSource" class="com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper" >
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver" />
<property name="url" value="jdbc:mysql://mysql.robinluo.top/activiti?characterEncoding=UTF-8&nullCatalogMeansCurrent=true&serverTimezone=GMT&useSSL=false" />
<property name="username" value="admin" />
<property name="password" value="RobinLuo@2021" />
</bean>
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- ... -->
<property name="databaseSchemaUpdate" value="true" />
<property name="dataSource" ref="dataSource" />
</bean>
</beans>