简体   繁体   中英

Spring:xml config convert to java config

Im using activiti and spring in project, XML manner previously configured as follows:

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

How is configured to convert into JAVA?

Something like that:

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

See also documentation: http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/beans.html#beans-factory-class-instance-factory-method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM