Spring学习之路

(一)搭建Spring.NET环境常见的DLL 

1.spring.core --整个框架的基础,实现了依赖注入的功能

2.Spring.AOP--提供面向方面编程(aop)的支持

3.Spring.Data--a定义了一个抽象的数据访问层,可以跨越各种数据访问技术(从ADO.NET到各种orm)进行数据访问。

4.Common.Logging.dll

(二)配置文件的设置

1.XML文件的配置

    复制到输出目录:始终复制

 

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.net
        http://www.springframework.net/xsd/spring-objects.xsd">
  <object id="类名" type="完整的类名,程序集名" singleton="true" >

    //如果类中包含其他类的话
    <property name="属性名" ref="类名" ></property>

    //类中属性的赋值
    <property name="属性名" value="值"></property>
  </object>
  <object id="类名" type="完整的类名,程序集名"  singleton="true">
    <property name="属性名" value="值"></property>
  </object>
</objects>

1.appconfig

<?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>
     //XML的位置
      <resource uri="file://XXX.xml"></resource>
    </context>
    <objects  xmlns="http://www.springframework.net">
    
    </objects>
  </spring>
</configuration>

 

posted @ 2017-12-05 13:43  Be_YourSelf夏  阅读(276)  评论(0编辑  收藏  举报