Spring.Net 配置文件
方法一. 直接在程序配置文件中配置
<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 配置文件的更多相关文章
- Spring的配置文件
Web.xml将会配置Spring的配置文件位置: <servlet> <servlet-name>x</servlet-name> & ...
- java Spring使用配置文件读取jdbc.properties
Spring使用配置文件读取jdbc.properties 在beans.xml中加入两个必须的bean [html]<bean id="propertyConfigurer" ...
- 使用JDom解析XML文档模拟Spring的配置文件解析
在J2EE项目中可能会涉及到一些框架的使用,最近接触到了SSH,拿Spring来说配置文件的使用是相当重要的,Spring的配置文件是一个xml文件,Spring是如何读取到配置文件并进行依赖注入的呢 ...
- Spring Boot 配置文件详解
Spring Boot配置文件详解 Spring Boot提供了两种常用的配置文件,分别是properties文件和yml文件.他们的作用都是修改Spring Boot自动配置的默认值.相对于prop ...
- Spring boot 配置文件详解 (properties 和yml )
从其他框架来看 我们都有自己的配置文件, hibernate有hbm,mybatis 有properties, 同样, Spring boot 也有全局配置文件. Springboot使用一个全局的配 ...
- Springboot 系列(二)Spring Boot 配置文件
注意:本 Spring Boot 系列文章基于 Spring Boot 版本 v2.1.1.RELEASE 进行学习分析,版本不同可能会有细微差别. 前言 不管是通过官方提供的方式获取 Spring ...
- java web路径和spring读取配置文件
此篇博客缘起:部署java web系统到阿里云服务器(ubuntu14.04)的时候,有以下两个问题 找不到自定义的property配置文件 上传图片的时候找不到路径 开发的时候是在windows上的 ...
- 史上最全的Spring Boot配置文件详解
Spring Boot在工作中是用到的越来越广泛了,简单方便,有了它,效率提高不知道多少倍.Spring Boot配置文件对Spring Boot来说就是入门和基础,经常会用到,所以写下做个总结以便日 ...
- spring boot 配置文件
spring boot使用一个全局配置文件:主要是以下两种类型 application.properties :例:server.port=9998 application.yml(YAML) : ...
- Spring之配置文件bean作用域的详细介绍
Spring的配置文件applicationContext.xml中bean作用域的详细介绍: 1:对象的创建:单例和多例 scope="singleton",默认值 ...
随机推荐
- bzoj专题训练
//http://blog.csdn.net/PoPoQQQ/article/category/2542243
- 比较和排序(IComparable和IComparer以及它们的泛型实现)
本文摘要: 1:比较和排序的概念: 2:IComparable和IComparer: 3:IComparable和IComparer的泛型实现IComparable<T>和ICompare ...
- react-router
基本的构建 import ReactRouter from 'react-router'; let {Route, Router, Link, IndexRoute} = ReactRouter.Ro ...
- ajax无刷新异步传输
index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- linux系统下本地搭建git服务器
linux系统下如何搭建本地git服务器,用于存放团队的开发代码,如下步骤: 1.先用一台服务器来安装git,安装好linux以后,在这里选用的是Ubuntu 14.04.然后配置静态IP:172.1 ...
- datagrid点击标题进行排序
步骤: 1.页面上首先设置datagrid的AllowSorting="true",以及指定排序方法OnSortCommand="DataGrid1_SortComman ...
- Teamwork[HDU4494]
Teamwork Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submi ...
- BZOJ1931 : [Shoi2007]Permutation 有序的计数
枚举LCP以及下一位变小成什么,统计出剩下的有几个可以在原位置. 然后枚举剩下的至少有几个在原位置,容斥计算答案. 时间复杂度$O(n^3)$. #include<cstdio> type ...
- 比较好用的php函数
eval(); $b = 2;$c = "+";$d = 3;eval("\$a=$b$c$d;"); //字符串相加,取值 (加减乘除都行) str_repl ...
- mysql 连接超时解决
修改my.cnf文件即可. ************************************ 在/etc/my.cnf下添加如下两行代码: wait_timeout=31536000inter ...