Spring:xml config转换为java config

时间:2014-06-09 08:35:40

标签: java xml spring

我在项目中使用activiti和spring, 以前配置的XML方式如下:

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

如何配置转换为JAVA?

1 个答案:

答案 0 :(得分:1)

类似的东西:

@Autowired
@Bean(name = "repositoryService"
RepositoryService createRepositoryService(ProcessEngine processEngine) {
    return processEngine.getRepositoryService();
}

另见文档:http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/beans.html#beans-factory-class-instance-factory-method