Bean要意识到Spring容器的存在,才能调用Spring所提供的资源(服务) --- Spring Aware
由于ApplicationContext 集成了所有Spring容器的服务,所以只要Bean实现ApplicationContextAware接口,即可调用Spring容器提供的所有服务,当然也可以只实现需要的服务的Aware接口。
// 该实现即是把ApplicationContext注入实现类中
public interface ApplicationContextAware extends Aware {
void setApplicationContext(ApplicationContext var1) throws BeansException;
}
Profile 支持不同环境下使用不同的配置 ( dev : 开发环境 , prod : 生产环境) (几种设定profile的方法 -- 待加超链)
Spring容器/IoC容器 : ApplicationContext <--- AnnotationConfigWebApplicationContext
WebApplicationInitialized 是Spring提供用来配置 Servlet3.0+配置的接口,从而实现替代web.xml 。
实现此接口的类将会自动被SpringServletContainerInitializer(用于启动Servlet3.0容器) 获取到。
SpringMVC常用注解 (@Controller | @RequestMapping | @RequestBody | @PathVariable | @RestController)