说明:接续Spring.Net 简单实例-01(IOC)

话不多说看操作

1:为UserInfo添加属性Spring.Net 简单实例-02(属性注入)

2: 修改App.config中代码

Spring.Net 简单实例-02(属性注入)

 

<?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"/>
    </context>
    <objects xmlns="http://www.springframework.net">
      <description>An  example that demonstrates simple IoC features.</description>
      <!--//type属性值必须是包含程序集名称在内的类型全名    "命名空间,程序集"-->
      <object name="UserInfoService"  type="YK.OA.SpringNet.UserInfoService, YK.OA.SpringNet">
        <!-- using setter injection... -->
        <!--//name代表属性名:UserName-->
        <property name="UserName" value="逍遥小天狼"/>
        </object>
    </objects>
  </spring>
</configuration>
App.config

相关文章:

  • 2022-03-07
  • 2021-06-22
  • 2021-12-17
  • 2021-06-14
  • 2022-12-23
  • 2021-06-01
  • 2021-09-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
  • 2021-05-27
  • 2021-08-17
相关资源
相似解决方案