Spring常见面试题总结

来源:互联网 发布:数据库培训内容 编辑:程序博客网 时间:2024/06/06 01:39

1、Spring里面applicationContext.xml文件能不能改成其他文件名?

ContextLoaderListener是一个ServletContextListener, 它在你的web应用启动的时候初始化。缺省情况下, 它会在WEB-INF/applicationContext.xml文件找Spring的配置。 你可以通过定义一个<context-param>元素名字为”contextConfigLocation”来改变Spring配置文件的 位置。示例如下: 

<listener>     <listener-class>org.springframework.web.context.ContextLoaderListener            <context-param>         <param-name>contextConfigLocation</param-name>         <param-value>/WEB-INF/xyz.xml</param-value>        </context-param>           </listener-class> </listener> 

2、spring中的BeanFactory与ApplicationContext的作用有哪些?

1. BeanFactory负责读取bean配置文档,管理bean的加载,实例化,维护bean之间的依赖关系,负责bean的声明周期。
2. ApplicationContext除了提供上述BeanFactory所能提供的功能之外,还提供了更完整的框架功能:

a. 国际化支持
b. 资源访问:Resource rs = ctx. getResource(”classpath:config.properties”), “file:c:/config.properties”

c. 事件传递:通过实现ApplicationContextAware接口

3、什么是aop,aop的作用是什么? 




原创粉丝点击