1、第一步在开发中,不可避免需要使用到spring容器本身的功能和资源,这时bean需要意识到spring容器的存在,才能使用spring提供的资源,这就是所谓的spring aware
2、第二步spring Aware的目的是为了将bean获得spring容器的服务,appli罕铞泱殳cationC泠贾高框ontext接口集成了MessageSource接口、applicationEvenPublisher接口 ResourceLoader接口
3、第三步Bean集成了ApplicationContextArea可以获得spring容器的所有服务,但是原则上还是用到什么接口,就实现什么接口
4、第四步上一步定义了spring容器的工厂类,在项目实际使用中,如下图:
5、第五步实现BeanNameAware/ResourceLoaderAware接口,可以获得幞洼踉残Bean名称和加载的服务实现Resource讣嘬铮篌LoaderAware需要重写 setresourceLoader实现beanNameAware需要重写setBeanName方法