首页 > 代码库 > spring静态工厂方法得到单例bean
spring静态工厂方法得到单例bean
import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Repository; public final class TaskFactory { private static TaskFactory instance; private TaskFactory() { } public static TaskFactory getInstance() { if (instance == null) { instance = new TaskFactory(); } return instance; } }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <description></description> <bean id="taskFactory" class="com.yundaex.common.parent.threadpool.TaskFactory" factory-method="getInstance"> </bean> </beans>
spring静态工厂方法得到单例bean
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。