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 容器初始化方法的更多相关文章

  1. spring容器初始化执行某个方法

    在做web项目开发中,尤其是企业级应用开发的时候,往往会在工程启动的时候做许多的前置检查. 比如检查是否使用了我们组禁止使用的Mysql的group_concat函数,如果使用了项目就不能启动,并指出 ...

  2. 当spring 容器初始化完成后执行某个方法

    在做web项目开发中,尤其是企业级应用开发的时候,往往会在工程启动的时候做许多的前置检查. 比如检查是否使用了我们组禁止使用的Mysql的group_concat函数,如果使用了项目就不能启动,并指出 ...

  3. 当spring 容器初始化完成后执行某个方法 防止onApplicationEvent方法被执行两次

    在做web项目开发中,尤其是企业级应用开发的时候,往往会在工程启动的时候做许多的前置检查. 比如检查是否使用了我们组禁止使用的Mysql的group_concat函数,如果使用了项目就不能启动,并指出 ...

  4. spring容器初始化bean和销毁bean之前进行一些操作的定义方法

    关于在spring  容器初始化 bean 和销毁前所做的操作定义方式有三种:        第一种,通过在xml中定义init-method和destory-method方法        第二种, ...

  5. 【Spring实战】Spring容器初始化完成后执行初始化数据方法

    一.背景知识及需求 在做WEB项目时,经常在项目第一次启动时利用WEB容器的监听.Servlet加载初始化等切入点为数据库准备数据,这些初始化数据是系统开始运行前必须的数据,例如权限组.系统选项.默认 ...

  6. ApplicationListener接口,在spring容器初始化后执行的方法

    一.如果我们希望在Spring容器将所有的Bean都初始化完成之后,做一些操作,那么就可以使用ApplicationListener接口,实现ApplicationListener接口中的onAppl ...

  7. Spring容器初始化数据(数据库)BeanPostProcessor的应用

    1.目的:在Spring启动的时候加载在数据库保存的配置信息,一方面杜绝随意修改,一方面方便管理 2.BeanPostProcessor是Spring提供的一个方法通过implements方式实现 会 ...

  8. Spring容器初始化过程

    一.Spring 容器高层视图 Spring 启动时读取应用程序提供的Bean配置信息,并在Spring容器中生成一份相应的Bean配置注册表,然后根据这张注册表实例化Bean,装配号Bean之间的依 ...

  9. 获取spring容器对象方法和原因

    为什么要获取Spring容器对象:拿到spring容器对象后,你就可以用spring管理的bean了,拿到bean,自然可以使用bean的方法,场景:比如jsp页面.通过注解是无法注入bean的,在开 ...

随机推荐

  1. hdu 1540 Tunnel Warfare (线段树,维护当前最大连续区间)

    Description During the War of Resistance Against Japan, tunnel warfare was carried out extensively i ...

  2. [CSP-S模拟测试]:抽卡(概率DP)

    题目描述 水上由岐最近在肝手游,游戏里有一个氪金抽卡的活动.有$n$种卡,每种卡有 3 种颜色.每次抽卡可能什么也抽不到,也可能抽到一张卡.每氪金一次可以连抽 m 次卡,其中前$m−1$次抽到第$i$ ...

  3. IE11“__doPostBack”未定义”

    IE 11 下<asp:LinkButton> 点击出现 “__doPostBack”未定义” 在项目根目录 App_Browsers 下新建 浏览器文件(.browser),让其与IE1 ...

  4. (转)Android OpenGL ES(一)

    转:http://wiki.jikexueyuan.com/project/opengl-es-guide/pipeline.html OpenGL ES 主要用来开发 3D 图形应用的.OpenGL ...

  5. 查看静态库(.lib)和动态库(.dll)的导出函数的信息 error LNK2001: 无法解析的外部符号 _Delete

    转自VC错误:http://www.vcerror.com/?p=1381 在window下查看动态库的导出函数可以用vs自带的Dependenc工具: 查看静态库的信息要用命令行来实现: 首先运行V ...

  6. D3DPT_TRIANGLESTRIP 与 D3DPT_TRIANGLEFAN 的区别

    D3DPT_TRIANGLESTRIP D3DPT_TRIANGLEFAN http://community.fortunecity.ws/skyscraper/sun/575/Programs/D3 ...

  7. 数据访问层的接口IBaseDAL

    using System; using System.Collections; using System.Data; using System.Data.Common; using System.Co ...

  8. Nginx网络架构实战学习笔记(三):nginx gzip压缩提升网站速度、expires缓存提升网站负载、反向代理实现nginx+apache动静分离、nginx实现负载均衡

    文章目录 nginx gzip压缩提升网站速度 expires缓存提升网站负载 反向代理实现nginx+apache动静分离 nginx实现负载均衡 nginx gzip压缩提升网站速度 网页内容的压 ...

  9. 在使用 Eclisp 生成 实体(sql Server) 出现错误 :Unable to locate JAR/zip in file system as specified by the driver definition: sqljdbc.jar.

    错误: 解决方法: 第一步:点击 JAR List 第二步:  点击  Remove  JAR/ZIP 第三步: 再添加一下 sqljdbc.jar

  10. 什么是索引?Mysql目前主要的几种索引类型

    一.索引 MySQL索引的建立对于MySQL的高效运行是很重要的,索引可以大大提高MySQL的检索速度. 打个比方,如果合理的设计且使用索引的MySQL是一辆兰博基尼的话,那么没有设计和使用索引的My ...