开发者社区> 毒逆天> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

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

简介:
+关注继续查看

案例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

 

 解释如图:

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
SSM框架整合—详细整合教程(Spring+SpringMVC+MyBatis)
SSM框架整合—详细整合教程(Spring+SpringMVC+MyBatis)
52 0
SpringBoot系列:MybatisPlus的入门级使用教程(下)
距离上一篇文章已经过去一个多月了,最近忙着项目上线,连轴转了一个多月,头发都少了不少!今天分享的是MP入门使用教程的最后的部分,也是使用的比较多的地方,就是如何使用MP进行条件查询!
128 0
SpringBoot系列:MybatisPlus的入门级使用教程(中)
距离上一篇文章已经过去一个多礼拜了!年后第一周就各种加班,忙成狗,今天分享的是MP入门使用教程的中篇部分!
60 0
springmvc与mybatis的整合
整合的思路 springmvc+mybatis的系统架构: image.png 第一步:整合持久层(dao) mybatis和spring整和,使用mapper的扫描器自动扫描mapper接口在spring中进行注册 第二步:整合service 通过spring管理service接口 使用配置方式蒋service接口配置在spring配置文件中。
906 0
SSM中(Spring-SpringMVC-Mybatis)(一:概念)
一:Spring: 参照我的另一篇博客:    http://www.cnblogs.com/GH0522/p/8127530.html 二:SpringMVC: 流程图: SpringMVC接口解释 DispatcherServlet: Spring提供的前端控制器,所有的请求都有经过它来统一分发。
1457 0
SpringMvc+Spring+MyBatis 基于注解整合
最近在给学生们讲Spring+Mybatis整合,根据有的学生反映还是基于注解实现整合便于理解,毕竟在先前的工作中团队里还没有人完全舍弃配置文件进行项目开发,由于这两个原因,我索性参考spring官方文档研究出完全基于注解整合ssm框架。
9723 0
SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a724888/article/details/63252941  SSM框架—...
1732 0
+关注
毒逆天
目前不太用云栖, 博客园地址:http://dunitian.cnblogs.com;GitHub地址:https://github.com/dunitian
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Java Spring Boot开发实战系列课程【第7讲】:Spring Boot 2.0安全机制与MVC身份验证实战(Java面试题)
立即下载
Java Spring Boot开发实战系列课程【第15讲】:Spring Boot 2.0 API与Spring REST Docs实战
立即下载
Spring框架入门
立即下载