①:创建applicationContext.xml配置文件放在src下

//applicationContext.xml代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<bean id="student" class="entity.Student" scope="prototype"></bean>
</beans>

②:导入ioc jar包并创建对应的java类(entity.Studen);

commons-logging.jar

spring-beans-版本号.RELEASE.jar

spring-context-版本号.RELEASE.jar

spring-core-版本号.RELEASE.jar

spring-expression-版本号.RELEASE.jar

③:加载配置文件创建实例

String str="applicationContext.xml";
ApplicationContext ac=
new ClassPathXmlApplicationContext(str);
Student s =ac.getBean("student",Student.class);

spring的配置文件和加载的更多相关文章

  1. Spring Cloud配置文件加载优先级简述

    Spring Cloud中配置文件的加载机制与其它的Spring Boot应用存在不一样的地方:如它引入了bootstrap.properties的配置文件,同时也支持从配置中心中加载配置文件等:本文 ...

  2. Spring之配置文件加载方式

    spring在org.springframework.core.io包中提供了多种配置文件加载方式.无论是XML.URL还是文件,都有很好的支持.比如基于URL的UrlResource.基于输入流的I ...

  3. Spring Web 配置文件加载路径问题

    Spring:   定位   载入   注册 我们常用的加载context文件的方法有如下三个: 1.FileSystemXmlApplicationContext 这个方法是从文件绝对路径加载配置文 ...

  4. Spring boot 配置文件 加载顺序

    springboot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 –file:./config/ – ...

  5. 【串线篇】spring boot配置文件加载位置

    springboot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 (1)–file:./config/ ...

  6. Spring Boot配置文件加载顺序

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.通过spring.config.location改变配置文件的位置 二.外部配置加载顺序 1.使用命令行参数指定加 ...

  7. Spring Bean注册和加载

    Spring解密 - XML解析 与 Bean注册 Spring解密 - 默认标签的解析 Spring解密 - 自定义标签与解析 Spring解密 - Bean的加载流程

  8. spring之:XmlWebApplicationContext作为Spring Web应用的IoC容器,实例化和加载Bean的过程

    它既是 DispatcherServlet 的 (WebApplicationContext)默认策略,又是 ContextLoaderListener 创建 root WebApplicationC ...

  9. Spring boot 配置文件默认放置位置,和加载优先级

    一 .默认配置文件目录 spring boot 启动会扫描以下位置的application.properties 或者application.yml文件作为spring boot 的默认配置文件 ,加 ...

随机推荐

  1. 手脱ASPack

    ESP定律到达OEP,重新分析代码块 在菜单栏中找到OllyDump插件,该插件的窗口的弹了出来,有一些选项可供我们修改,我们可以对Base of Code进行修改,这里Base of Code = ...

  2. iOS tableview group时头尾视图间隔大小

    解决: 一,当使用tableview的格式为group时 1.先设置 tableview.sectionHeaderHeight = 0.00001; tableview.sectionFooterH ...

  3. volatile可见性的一些认识

    一.前言 volatile的关键词的使用在JVM内存模型中已是老生常谈了,这篇文章主要结合自己对可见性的一些认识和一些直观的例子来谈谈volatile.文章正文大致分为三部分,首先会介绍一下happe ...

  4. 在 Android 中如何优雅地配置私密信息

    在实际的项目开发中,经常会用到一些第三方的 SDK ,而使用这些 SDK 基本上都是需要配置 APPKEY 或 APPSECRET 等信息.此外 APP 打包时需要 KEYSTORE , STOREP ...

  5. FxZ,C#开发职位面试测试题(30分钟内必须完成)

    1. Refactor the following code (C#) to use polymorphism instead of if-else. Please provide your answ ...

  6. Session的引入以及Cookie的不足

    一.为什么引入session > Cookie实际上就是一个头. > 服务器会创建Cookie,并且将Cookie以一个响应头的形式发送给浏览器        > 浏览器收到Cook ...

  7. 从"汉诺塔"经典递归到JS递归函数

    前言 参考<JavaScript语言精粹> 递归是一种强大的编程技术,他把一个问题分解为一组相似的子问题,每一问题都用一个寻常解去解决.递归函数就是会直接或者间接调用自身的一种函数,一般来 ...

  8. Android 开场动画

    呼,忙了两天了这个,找了各种资料,勉勉强强实现我的功能,这个还得改进一下,线程方面的知识没有学到多少,弄了线程画UI有着各种bug,无奈..就这样跳过先了,哪一天有时间在回来搞一下. 正文———— 要 ...

  9. 80C51 K1控制D1发光

    #include "reg52.h" typedef unsigned char u8; typedef unsigned int u16; sbit led = P2^0; sb ...

  10. 80C51 数码管动态显示0~7

    所使用的开发板 普中科技HC6800-ES V2.0 PC:win7 64位 编译软件: keil uversion2 烧写工具: 普中科技开发的PZ-ISP V1.82 烧写方式:热烧写 #incl ...