在app-dao.xml文件添加如下内容
<!-- activiti5集成spring配置 -->
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
<property name="jpaHandleTransaction" value="true" />
<property name="deploymentResources" value="classpath:/diagram/leave.zip" />
<property name="jpaCloseEntityManager" value="true" />
<property name="jobExecutorActivate" value="false" />
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
<bean id="formService" factory-bean="processEngine" factory-method="getFormService" />
新建一个测试类
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:config/app-dao.xml" })
public class TestLeave {
@Autowired
@Qualifier("userRepository")
UserRepository ur;//用户
@Autowired
@Qualifier("roleRepository")
RoleRepository rr;//权限
@Autowired
private RuntimeService runtimeService;//开始
@Autowired
private TaskService taskService;//流程
@Autowired
private HistoryService historyService;//历史流程(包括还在运行的流程)
@Autowired
private IdentityService identityService;
@Test
public void TestRun() {//
}
}