学习java第一百四十二天

ApplicationContext通常的实现是什么?

FileSystemXmlApplicationContext :此容器从一个XML文件中加载beans的定义,XML Bean配置文件的全路径名必须提供给它的构造函数 ApplicationContext context = new FileSystemXmlApplicationContext("bean.xml");

ClassPathXmlApplicationContext:从classpath的XML配置文件中读取上下文,并生成上下文定义。应用程序上下文从程序环境变量中 ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");

WebXmlApplicationContext:由Web应用的XML文件读取上下文。

解释Spring支持的几种bean的作用域。

Spring框架支持以下五种bean的作用域:

singleton : bean在每个Spring ioc 容器中只有一个实例。

prototype:一个bean的定义可以有多个实例。

-request:每次http请求都会创建一个bean,该作用域仅在基于web的Spring ApplicationContext情形下有效。

session:在一个HTTP Session中,一个bean定义对应一个实例。该作用域仅在基于web的Spring ApplicationContext情形下有效。

global-session:在一个全局的HTTP Session中,一个bean定义对应一个实例。该作用域仅在基于web的Spring ApplicationContext情形下有效。

缺省的Spring bean 的作用域是Singleton.

相关推荐
好奇龙猫2 分钟前
[大学院-python-base gammer learning2: python base programming ]
开发语言·python
夹芯饼干10 分钟前
虚拟机指令第六节
java·linux·服务器
海盗123420 分钟前
C#上位机开发-S7协议通信
开发语言·c#
STLearner20 分钟前
AI论文速读 | QuitoBench:支付宝高质量开源时间序列预测基准测试集
大数据·论文阅读·人工智能·深度学习·学习·机器学习·开源
小短腿的代码世界25 分钟前
Qt 2D 绘制实战与性能优化深度解析
开发语言·qt·性能优化
FeBaby32 分钟前
ReentrantLock 与 synchronized 底层实现对比图解
开发语言·c#
jaycyj33 分钟前
pytest
开发语言·python
A_aspectJ36 分钟前
【Java基础开发】基于 Java Swing +MySQL + JDBC 版实现图书管理系统
java·开发语言·mysql
TE-茶叶蛋36 分钟前
Spring最核心扩展点:BeanPostProcessor
java·后端·spring
Mr.456737 分钟前
SpringBoot多模块依赖冲突排查与架构优化实战(避坑指南)
java·spring boot·架构