一、引出正题
业务背景: 我要从Spring IOC容器中获取bean,应该如何获取?
引发思考: 从IOC容器中获取bean,那我们就是要获取一个ApplicationContext
应用上下对象,然后调用其父类的getBean(String name)
就可以拿到我们想要的bean了。既然如此,那接下去让我们看个示例吧!
二、场景示例
@Component
public class SubApplicationContextAware implements ApplicationContextAware {
private static ApplicationContext applicationContext;