方法一. 直接在程序配置文件中配置

 <configuration>

   <configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections> <spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="Person" type="PhoneNumberWhere.Person, PhoneNumberWhere"> //类的全名称,程序集名称
<property name="Name" value="MyName"/>     //简单属性配置,key-value
<property name="SonMan" ref="Son"/>      //复杂属性配置,ref
</object>
<object id="Son" type="PhoneNumberWhere.Son, PhoneNumberWhere"> //
</object>
</objects>
</spring> </configuration>

方法二. 引用外部xml文件配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration> <configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections> <spring>
<context>
<resource uri="config://spring/objects"/>
<resource uri="file://objs.xml"/> //引用xml文件,并把xml设置为【始终复制】嵌入的资源
</context>
<objects xmlns="http://www.springframework.net">
</objects>
</spring>
</configuration>

objs.xml文件

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object id="Person" type="PhoneNumberWhere.Person, PhoneNumberWhere">
<property name="Name" value="MyName"/>
<property name="SonMan" ref="Son"/>
</object>
<object id="Son" type="PhoneNumberWhere.Son, PhoneNumberWhere">
<constructor-arg index="0" value="son.txt"/>
</object>
</objects>

创建对象【引用  Spring.Core.dlll   Common.Logging.dll】

IApplicationContext ctx = ContextRegistry.GetContext();
Person person = (Person)ctx.GetObject("Person");

Spring.Net 配置文件的更多相关文章

  1. Spring的配置文件

    Web.xml将会配置Spring的配置文件位置: <servlet>        <servlet-name>x</servlet-name>        & ...

  2. java Spring使用配置文件读取jdbc.properties

    Spring使用配置文件读取jdbc.properties 在beans.xml中加入两个必须的bean [html]<bean id="propertyConfigurer" ...

  3. 使用JDom解析XML文档模拟Spring的配置文件解析

    在J2EE项目中可能会涉及到一些框架的使用,最近接触到了SSH,拿Spring来说配置文件的使用是相当重要的,Spring的配置文件是一个xml文件,Spring是如何读取到配置文件并进行依赖注入的呢 ...

  4. Spring Boot 配置文件详解

    Spring Boot配置文件详解 Spring Boot提供了两种常用的配置文件,分别是properties文件和yml文件.他们的作用都是修改Spring Boot自动配置的默认值.相对于prop ...

  5. Spring boot 配置文件详解 (properties 和yml )

    从其他框架来看 我们都有自己的配置文件, hibernate有hbm,mybatis 有properties, 同样, Spring boot 也有全局配置文件. Springboot使用一个全局的配 ...

  6. Springboot 系列(二)Spring Boot 配置文件

    注意:本 Spring Boot 系列文章基于 Spring Boot 版本 v2.1.1.RELEASE 进行学习分析,版本不同可能会有细微差别. 前言 不管是通过官方提供的方式获取 Spring ...

  7. java web路径和spring读取配置文件

    此篇博客缘起:部署java web系统到阿里云服务器(ubuntu14.04)的时候,有以下两个问题 找不到自定义的property配置文件 上传图片的时候找不到路径 开发的时候是在windows上的 ...

  8. 史上最全的Spring Boot配置文件详解

    Spring Boot在工作中是用到的越来越广泛了,简单方便,有了它,效率提高不知道多少倍.Spring Boot配置文件对Spring Boot来说就是入门和基础,经常会用到,所以写下做个总结以便日 ...

  9. spring boot 配置文件

    spring boot使用一个全局配置文件:主要是以下两种类型 application.properties  :例:server.port=9998 application.yml(YAML)  : ...

  10. Spring之配置文件bean作用域的详细介绍

    Spring的配置文件applicationContext.xml中bean作用域的详细介绍: 1:对象的创建:单例和多例        scope="singleton",默认值 ...

随机推荐

  1. 数据库ORM框架GreenDao

    常用的数据库: 1). Sql Server2). Access3). Oracle4). Sysbase5). MySql6). Informix7). FoxPro8). PostgreSQL9) ...

  2. 【java基础】内存分析

    在上次我们说的<重载与重写>呢,我们遗留了一个问题,就是运行结果的各异性,那今天,我们就来探究一下         内存里的天地.                  首先呢,我们把mian ...

  3. 性能测试中TPS和并发用户数

    并发用户数与TPS之间的关系 1.  背景 在做性能测试的时候,很多人都用并发用户数来衡量系统的性能,觉得系统能支撑的并发用户数越多,系统的性能就越好:对TPS不是非常理解,也根本不知道它们之间的关系 ...

  4. Js图片切换

    <!DOCTYPE html><html<head> <meta charset="UTF-8"> <title></t ...

  5. Android 编程下 DP、SP 以及屏幕像素密度

    有时需为视图属性指定大小尺寸值(通常以像素为单位,但有时也用点.毫米或英寸).最常见的属性有: 文字大小(Text Size),指设备上显示的文字像素高度: 边距(Margin),指定视图组件间的距离 ...

  6. poj2184 01背包变形,价值为可为负数

    题目链接:http://poj.org/problem?id=2184 题意:每行给出si和fi,代表牛的两个属性,然后要求选出几头牛,满足S与F都不能为负数的条件下,使S与F的和最大. tips:动 ...

  7. Thymeleaf 集成spring

    Thymeleaf 集成spring 如需先了解Thymeleaf的单独使用,请参考<Thymeleaf模板引擎使用>一文. 依赖的jar包 Thymeleaf 已经集成了spring的3 ...

  8. volicity 模板类,java操作配置文件

    import java.io.StringWriter; import java.util.HashSet; import java.util.Iterator; import java.util.M ...

  9. LA6886 Golf Bot(FFT)

    题目 Source https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page= ...

  10. uva-465(overflow)

    这道题很奇葩啊,WA了4发...妈的,用c++也不至于,输出竟然要原样输出... 例如: 0000000000000000006 * 000000000000001 输出是 0000000000000 ...