Spring 5 中的 BeanFactoryLocator 替代品
我们使用 4.2.x 版本的 spring,并使用 BeanFactoryLocator 从 xml 文件创建工厂。
返回 Beanfactory 的方法:
private BeanFactory createServicesContainer() {
BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance("Connector.xml");
BeanFactoryReference bfReference = bfLocator.useBeanFactory("bigBean");
return bfReference.getFactory();
}
我的 Connector.xml 文件包含:
<?xml version="1.0" encoding="UTF-8"?>
<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-2.5.xsd"
default-lazy-init="false">
<!--
The Big Bean for accessing all the repository services. This factory bean serves as
and umbrella bean for all the underlying repository services.
-->
<bean id="bigBean" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>sample1-connector.xml</value>
<value>sample2-connector.xml</value>
<value>sample3-connector.xml</value>
</list>
</constructor-arg>
</bean>
</beans>
现在如何更改它以使其在 Spring 5.x 中工作
We were using 4.2.x version of spring and we are using BeanFactoryLocator to create a factory from xml file.
method to return Beanfactory:
private BeanFactory createServicesContainer() {
BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance("Connector.xml");
BeanFactoryReference bfReference = bfLocator.useBeanFactory("bigBean");
return bfReference.getFactory();
}
my Connector.xml file contains:
<?xml version="1.0" encoding="UTF-8"?>
<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-2.5.xsd"
default-lazy-init="false">
<!--
The Big Bean for accessing all the repository services. This factory bean serves as
and umbrella bean for all the underlying repository services.
-->
<bean id="bigBean" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>sample1-connector.xml</value>
<value>sample2-connector.xml</value>
<value>sample3-connector.xml</value>
</list>
</constructor-arg>
</bean>
</beans>
Now how can make changes it to work in Spring 5.x
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论