Spring(十七):获取ApplicationContext方式,获取所有Bean和RequestMapping
Spring 项目经常需要拿到上下文,通过上下文来获取 IoC 容器中注册的 Bean。
获取上下文有好几种方式,可以实现 ApplicationContextAware 接口,可以通过 ServletContext 获取,而通过 ContextLoader 来获取上下文在 Spring Boot 中并不适用,适用于 Spring 项目。
Spring(十七):获取ApplicationContext方式,获取所有Bean和RequestMapping
Spring 项目经常需要拿到上下文,通过上下文来获取 IoC 容器中注册的 Bean。
获取上下文有好几种方式,可以实现 ApplicationContextAware 接口,可以通过 ServletContext 获取,而通过 ContextLoader 来获取上下文在 Spring Boot 中并不适用,适用于 Spring 项目。