博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring.Net在Mvc4.0中应用的说明
阅读量:5937 次
发布时间:2019-06-19

本文共 6561 字,大约阅读时间需要 21 分钟。

案例Demo:http://yunpan.cn/cJ5aZrm7Uybi3 访问密码 414b

Spring.Net在Mvc4.0中应用的说明

1.引用dll

 

 

 

2.修改Global文件 (SpringMvcApplication)

 

 

 

3.控制器添加属性

 

 

4.WebConfig配置

 

<!--必须紧跟着configuration之后-->

  <configSections>

    <sectionGroup name="spring">

      <section name="context" type="Spring.Context.Support.MvcContextHandler, Spring.Web.Mvc4"/>

    </sectionGroup>

  </configSections>

  <!--Spring.Net节点详细配置-->

  <spring>

    <context>

      <!--配置文件在网站根目录下的Config文件夹下的Spring.xml记得把xml文件设置成始终复制到输出目录-->

      <resource uri="file://~/Config/Spring.xml"/>

    </context>

  </spring>

  <!--Spring.Net节点详细配置结束-->

 

 

 

5.Spring.xml的配置(记得右键属性设置Spring.xml始终复制到输入目录)

 

<objects xmlns="http://www.springframework.net">

  <!--放容器里面的所有的节点  type属性的规范:程序集名称在内的类型全名,程序集名-->

  <object type="Spring.Net.MVCDemo.Controllers.UserInfoController,Spring.Net.MVCDemo" singleton="false" >

    <!--给UserInfoController注入UserRegInfoService对象-->

    <property name="UserRegInfoService" ref="UserRegInfoService" />

  </object>

 

  <!--配置Service-->

  <object name="UserRegInfoService" type="Spring.Net.MVCDemo.Service.UserRegInfoService,Spring.Net.MVCDemo.Service" singleton="false" >

  </object>

</objects>

 

 

6.注意此异常信息

Could not load type from string value 'Spring.Net.MVCDemo.Service.UserRegInfoService,Spring.Net.MVCDemo.Service'.

说明执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息System.TypeLoadException: Could not load type from string value 'Spring.Net.MVCDemo.Service.UserRegInfoService,Spring.Net.MVCDemo.Service'.
源错误: 

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪: 

 

[TypeLoadException: Could not load type from string value 'Spring.Net.MVCDemo.Service.UserRegInfoService,Spring.Net.MVCDemo.Service'.]

   Spring.Core.TypeResolution.TypeResolver.Resolve(String typeName) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Core\TypeResolution\TypeResolver.cs:81

   Spring.Core.TypeResolution.GenericTypeResolver.Resolve(String typeName) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Core\TypeResolution\GenericTypeResolver.cs:91

   Spring.Core.TypeResolution.CachedTypeResolver.Resolve(String typeName) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Core\TypeResolution\CachedTypeResolver.cs:107

   Spring.Core.TypeResolution.TypeResolutionUtils.ResolveType(String typeName) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Core\TypeResolution\TypeResolutionUtils.cs:101

   Spring.Objects.Factory.Support.AbstractObjectDefinition.ResolveObjectType() in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectDefinition.cs:639

   Spring.Objects.Factory.Support.AbstractObjectFactory.ResolveObjectType(RootObjectDefinition rod, String objectName) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectFactory.cs:1123

 

[CannotLoadObjectTypeException: Cannot resolve type [Spring.Net.MVCDemo.Service.UserRegInfoService,Spring.Net.MVCDemo.Service] for object with name 'UserRegInfoService' defined in file [C:\Users\DNT\Desktop\Spring.Net.MVCDemo\Spring.Net.MVCDemo\Spring.Net.MVCDemo\Config\Spring.xml] line 19]

   Spring.Objects.Factory.Support.AbstractObjectFactory.ResolveObjectType(RootObjectDefinition rod, String objectName) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectFactory.cs:1127

   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.PredictObjectType(String objectName, RootObjectDefinition mod) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\AbstractAutowireCapableObjectFactory.cs:160

   Spring.Objects.Factory.Support.DefaultListableObjectFactory.IsFactoryObject(String objectName, RootObjectDefinition rod) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\DefaultListableObjectFactory.cs:1079

   Spring.Objects.Factory.Support.DefaultListableObjectFactory.DoGetObjectNamesForType(Type type, Boolean includeNonSingletons, Boolean allowEagerInit) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\DefaultListableObjectFactory.cs:1011

   Spring.Objects.Factory.Support.DefaultListableObjectFactory.DoGetObjectsOfType(Type type, Boolean includePrototypes, Boolean includeFactoryObjects, IDictionary resultCollector) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\DefaultListableObjectFactory.cs:841

   Spring.Objects.Factory.Support.DefaultListableObjectFactory.GetObjectsOfType(Type type, Boolean includePrototypes, Boolean includeFactoryObjects) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Objects\Factory\Support\DefaultListableObjectFactory.cs:835

   Spring.Context.Support.AbstractApplicationContext.GetObjectsOfType(Type type, Boolean includePrototypes, Boolean includeFactoryObjects) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Context\Support\AbstractApplicationContext.cs:1476

   Spring.Context.Support.AbstractApplicationContext.GetObjectsOfType(Type type) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Core\Context\Support\AbstractApplicationContext.cs:1411

   Spring.Web.Mvc.SpringMvcDependencyResolver.GetService(Type serviceType) in f:\bamboo-home\xml-data\build-dir\SPRNET-RELEASE-JOB1\src\Spring\Spring.Web.Mvc4\SpringMvcDependencyResolver.cs:77

   System.Web.Mvc.DependencyResolverExtensions.GetService(IDependencyResolver resolver) +56

   System.Web.Mvc.SingleServiceResolver`1.GetValueFromResolver() +43

   System.Lazy`1.CreateValue() +416

   System.Lazy`1.LazyInitValue() +152

   System.Lazy`1.get_Value() +75

   System.Web.Mvc.SingleServiceResolver`1.get_Current() +15

   System.Web.Mvc.MvcRouteHandler.GetSessionStateBehavior(RequestContext requestContext) +125

   System.Web.Mvc.MvcRouteHandler.GetHttpHandler(RequestContext requestContext) +33

   System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler(RequestContext requestContext) +10

   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +9770076

   System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82

   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136

   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

 


版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34009

 

 解释如图:

转载地址:http://qcntx.baihongyu.com/

你可能感兴趣的文章
密码概述
查看>>
nagios+nrpe监控配置错误日志集
查看>>
《数据分析实战:基于EXCEL和SPSS系列工具的实践》——3.4 数据量太大了怎么办...
查看>>
JavaScript应用开发实践指南迷你书
查看>>
autoconf,automake,libtool
查看>>
jQuery的技巧01
查看>>
基于泛型实现的ibatis通用分页查询
查看>>
gopacket 使用
查看>>
AlertDialog对话框
查看>>
我的友情链接
查看>>
办公室几台电脑怎么连一台打印机的具体步骤
查看>>
linux安全---cacti+ntop监控
查看>>
鸟哥的linux私房菜-shell简单学习-1
查看>>
nagios配置监控的一些思路和工作流程
查看>>
iptables+layer7实现访问控制+netfilter/iptables基础
查看>>
通讯组基本管理任务三
查看>>
赫夫曼编码实现
查看>>
html页面显示div源代码
查看>>
基础复习-算法设计基础 | 复杂度计算
查看>>
debian、ubuntu系统下,常用的下载工具
查看>>