maven的pom文件
<!-- https://mvnrepository.com/artifact/org.activiti/activiti-engine --> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-engine</artifactId> <version>5.22.0</version> </dependency>
<!-- https://mvnrepository.com/artifact/org.activiti/activiti-spring --> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-spring</artifactId> <version>5.22.0</version> </dependency>
xml文件
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> <property name="datasource" ref="datasource"> <property name="transactionManager" ref="transactionManager"> <property name="databaseSchemaUpdate" value="true"> <!-- 创建流程引擎对象--> <bean id="processEngine" class="org.activiti.spring.ProcessEnginefactoryBean"> <property name="processEngineConfiguration" value="processEngineConfiguration"></property> </bean> <!--实例化各个service--> <bean id="repositoryService" factory-bean="processEngine" factory-method="getRespositoryService" /> .... 以此类推,构建以下各个bean runtimeService,taskService,formService,historyService,managementService,identityService
</bean>
构建出需要的各个service,就可以在前台直接注入了。
参考上一篇,spring的三种构建方式,
这里使用的是使用实例工厂方式构建,不是静态方法。