主要步骤如下
1.UI层中添加连接字符串 从Model层中复制
<connectionStrings>
<add name="DataModelContainer" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=LTeasyOAdb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
2.添加Spring.Net块配置
<configSections>
<!-- Entity Framework 块配置 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!--Spring.Net块配置-->
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.MvcContextHandler, Spring.Web.Mvc4"/>
</sectionGroup>
</configSections>
3.添加Spring需要的引用
4.修改Global 继承关系
5.复制Config文件
6.添加Spring配置的外部文件 注意顺序
7.定义 通过接口定义
<object type=" LTeasyOA.UI.Portal2.Controllers.UserInfoController, LTeasyOA.UI.Portal2" singleton="false" >
<property name="UserInfoService" ref="UserInfoService" />
<object> 定义对象
type(具体类名,类的命名空间)
<property/> 属性注入 name 属性名 ref引用 value值