spring的配置文件和加载
①:创建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的配置文件和加载的更多相关文章
- Spring Cloud配置文件加载优先级简述
Spring Cloud中配置文件的加载机制与其它的Spring Boot应用存在不一样的地方:如它引入了bootstrap.properties的配置文件,同时也支持从配置中心中加载配置文件等:本文 ...
- Spring之配置文件加载方式
spring在org.springframework.core.io包中提供了多种配置文件加载方式.无论是XML.URL还是文件,都有很好的支持.比如基于URL的UrlResource.基于输入流的I ...
- Spring Web 配置文件加载路径问题
Spring: 定位 载入 注册 我们常用的加载context文件的方法有如下三个: 1.FileSystemXmlApplicationContext 这个方法是从文件绝对路径加载配置文 ...
- Spring boot 配置文件 加载顺序
springboot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 –file:./config/ – ...
- 【串线篇】spring boot配置文件加载位置
springboot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 (1)–file:./config/ ...
- Spring Boot配置文件加载顺序
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.通过spring.config.location改变配置文件的位置 二.外部配置加载顺序 1.使用命令行参数指定加 ...
- Spring Bean注册和加载
Spring解密 - XML解析 与 Bean注册 Spring解密 - 默认标签的解析 Spring解密 - 自定义标签与解析 Spring解密 - Bean的加载流程
- spring之:XmlWebApplicationContext作为Spring Web应用的IoC容器,实例化和加载Bean的过程
它既是 DispatcherServlet 的 (WebApplicationContext)默认策略,又是 ContextLoaderListener 创建 root WebApplicationC ...
- Spring boot 配置文件默认放置位置,和加载优先级
一 .默认配置文件目录 spring boot 启动会扫描以下位置的application.properties 或者application.yml文件作为spring boot 的默认配置文件 ,加 ...
随机推荐
- Oracle execute and call
--execute和call的区别 -------------------------2014/01/14 EXEC is a sqlplus command that put its argumen ...
- KVO实现自定义文件复制进度展示
一.创建文件 说明:自定义文件类,通过NSFileManager 以及NSFileHandle 实现文件的创建和copy,为了控制内存的并发使用,通过控制每次赋值的固定长度来分多次复制: NSStri ...
- 神经网络与深度学习笔记 Chapter 1.
转载请注明出处:http://www.cnblogs.com/zhangcaiwang/p/6875533.html sigmoid neuron 微小的输入变化导致微小的输出变化,这种特性将会使得学 ...
- Shiro入门
Shiro是由Apache提供的一个强大且易用的Java安全开源框架,执行身份验证.授权.密码学和会话管理.使用Shiro的易于理解的API,您可以快速.轻松地获得任何应用程序,从最小的移动应用程序到 ...
- 内存数据库之Apache Ingite
上一篇文章,我们做了内存数据库的技术选型: 内存数据库技术选型 本文中,我们继续深入研究Apache Ignite,同时分享一些我们.Net的编码实践. 首先,Apache Ignite是一个内存数据 ...
- 【Ubuntu 16】安装deb
deb是debian linux的安装格式,跟red hat的rpm非常相似,最基本的安装命令是:dpkg -i file.deb dpkg 是Debian Package的简写,是为Debian ...
- 线性代数-矩阵-【4】点乘 C和C++的实现
点击这里可以跳转至 [1]矩阵汇总:http://www.cnblogs.com/HongYi-Liang/p/7287369.html [2]矩阵生成:http://www.cnblogs.com/ ...
- fzu1969 GCD Extreme 类似于uva10561
Description Given the value of N, you will have to find the value of G. The meaning of G is given in ...
- 安装python+setuptools+pip+nltk
环境:Win10 64 + python 2.7 32 bit Source installation (for 32-bit or 64-bit Windows) 1.Install Python: ...
- [2013-03-14]使用wiki维护产品文档
word文档作为产品文档的问题: word文档本身的设计是为了打印: word文档的编辑较为繁琐: 作为产品文档的word文档往往长达百页以上,难以维护,且容易分散注意力,不利于查阅: 没有一个简单易 ...