Spring 容器初始化方法
Resource resource = new ClassPathResource("/bean.xml");
resource = new FileSystemResource("d:/tzspring02/src/bean.xml");
XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(resource);
/*spring容器加载资源文件的核心类 PathMatchingResourcePatternResolver*/
ResourcePatternResolver resourceLoader = new PathMatchingResourcePatternResolver();
Resource resource = resourceLoader.getResource("classpath:bean.xml");//ClassPathResource
System.out.println(resource.getDescription()+"===="+resource.getFile().getAbsolutePath());
XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(resource);
System.out.println("########1");
ApplicationContext application1 = new ClassPathXmlApplicationContext("classpath:/com/easeye/conf/applicationContext.xml");
Student stu1 = application1.getBean("student",Student.class);
stu1.ShowInfo();
System.out.println("########2");
ApplicationContext application2 = new FileSystemXmlApplicationContext("file:D:/Software/apache-tomcat-7.0.59/webapps/SpringDemo/WEB-INF/classes/com/easeye/conf/applicationContext.xml");
Student stu2 = application2.getBean("student",Student.class);
stu2.ShowInfo();
System.out.println("########3");
ApplicationContext application3 = new AnnotationConfigApplicationContext("com.easeye.test");
Student stu3 = application3.getBean("student",Student.class);
stu2.ShowInfo();
Spring 容器初始化方法的更多相关文章
- spring容器初始化执行某个方法
在做web项目开发中,尤其是企业级应用开发的时候,往往会在工程启动的时候做许多的前置检查. 比如检查是否使用了我们组禁止使用的Mysql的group_concat函数,如果使用了项目就不能启动,并指出 ...
- 当spring 容器初始化完成后执行某个方法
在做web项目开发中,尤其是企业级应用开发的时候,往往会在工程启动的时候做许多的前置检查. 比如检查是否使用了我们组禁止使用的Mysql的group_concat函数,如果使用了项目就不能启动,并指出 ...
- 当spring 容器初始化完成后执行某个方法 防止onApplicationEvent方法被执行两次
在做web项目开发中,尤其是企业级应用开发的时候,往往会在工程启动的时候做许多的前置检查. 比如检查是否使用了我们组禁止使用的Mysql的group_concat函数,如果使用了项目就不能启动,并指出 ...
- spring容器初始化bean和销毁bean之前进行一些操作的定义方法
关于在spring 容器初始化 bean 和销毁前所做的操作定义方式有三种: 第一种,通过在xml中定义init-method和destory-method方法 第二种, ...
- 【Spring实战】Spring容器初始化完成后执行初始化数据方法
一.背景知识及需求 在做WEB项目时,经常在项目第一次启动时利用WEB容器的监听.Servlet加载初始化等切入点为数据库准备数据,这些初始化数据是系统开始运行前必须的数据,例如权限组.系统选项.默认 ...
- ApplicationListener接口,在spring容器初始化后执行的方法
一.如果我们希望在Spring容器将所有的Bean都初始化完成之后,做一些操作,那么就可以使用ApplicationListener接口,实现ApplicationListener接口中的onAppl ...
- Spring容器初始化数据(数据库)BeanPostProcessor的应用
1.目的:在Spring启动的时候加载在数据库保存的配置信息,一方面杜绝随意修改,一方面方便管理 2.BeanPostProcessor是Spring提供的一个方法通过implements方式实现 会 ...
- Spring容器初始化过程
一.Spring 容器高层视图 Spring 启动时读取应用程序提供的Bean配置信息,并在Spring容器中生成一份相应的Bean配置注册表,然后根据这张注册表实例化Bean,装配号Bean之间的依 ...
- 获取spring容器对象方法和原因
为什么要获取Spring容器对象:拿到spring容器对象后,你就可以用spring管理的bean了,拿到bean,自然可以使用bean的方法,场景:比如jsp页面.通过注解是无法注入bean的,在开 ...
随机推荐
- 集合类中的Collection接口实现类
今天学习一下集合包里面的内容,常见的有Collection和Map两个接口的实现类Collection中常见的又分为两种: 1.List ,支持放入重复的对象,实现类有arraylist,linked ...
- webpack中的url-loader
使用url-loader引入图片,可以说它是file-loader的增强版 url-loader会把我们的图片使用base64的形式编码成另外一种字符串,网页是可以识别这种编码的东西的,这样的好处是, ...
- 用 Flask 来写个轻博客 (12) — M(V)C_编写和继承 Jinja 模板
Blog 项目源码:https://github.com/JmilkFan/JmilkFan-s-Blog 目录 目录 前文列表 扩展阅读 使用 Bootstrap 编写 Jinja 模板文件 继承一 ...
- Jeecg_Jflow整合记录
系统组织机构 t_s_deparselect * from t_s_departselect * from t_s_depart where id='402888fd6a8c24e9016a8c531 ...
- 用processing生成屏保程序
想法 利用随机数控制圆圈的大小.位置以及颜色,可以产生随机的美感. 让小球动起来,并且在屏幕边界处产生反弹效果. 代码 1: float circle_x = (float) 0.0; 2: floa ...
- Python List reverse() 与list[::-1]
reverse() https://www.runoob.com/python/att-list-reverse.html list[::-1] https://blog.csdn.net/usern ...
- 字符串内置函数--str(object)
####最重要的6个魔法 join拼接 split分割 find查找 strip去空格 upper变大写 lower变小写 ###(一)拼接字符串 test = '用指定字符拼接字符串元素\n' v1 ...
- spring data jpa 关联设计
MAP关联实体 // @ElementCollection @OneToMany(cascade = {CascadeType.ALL})// @JoinColumn(name = "the ...
- Python面试题之“猴子补丁”(monkey patching)指的是什么?这种做法好吗?
“猴子补丁”就是指,在函数或对象已经定义之后,再去改变它们的行为. 举个例子: import datetime datetime.datetime.now = lambda: datetime.dat ...
- Pytest 通过文件名类名方法执行部分用例
• 场景:只执行符合要求的某一部分用例,通过类与方法的命名实 现.通常编写测试方法时 • 解决:直接输入文件名,类名 pytest test_class_01.py • pytest -v -s te ...