spring BeanFactory 的getbean 有几个重载的方法

2024-12-03 18:19:50
推荐回答(2个)
回答(1):

有四个:(要学会去查看spring的api)
1: T getBean(Class requiredType)
Return the bean instance that uniquely matches the given object type, if any.
2: Object getBean(String name)
Return an instance, which may be shared or independent, of the specified bean.
3: T getBean(String name, Class requiredType)
Return an instance, which may be shared or independent, of the specified bean.
4: Object getBean(String name, Object... args)
Return an instance, which may be shared or independent, of the specified bean.

回答(2):

2ge