【发布时间】:2012-06-07 19:03:21
【问题描述】:
我正在将一个使用 Spring.Net 和 NHibernate 运行的 ASP.NET Webform 应用程序移植到 ASP.NET MVC3。创建新项目并验证 Spring.Net 可以在同一解决方案中正确地跨项目注入依赖项后,我继续在新解决方案中导入服务和持久层项目。
我的映射现在看起来还不错(在本文末尾有更多信息),但是当我启动应用程序时,我收到以下错误:
在容器中找不到持久性异常转换器。不能 执行异常翻译。
[ConfigurationErrorsException:创建上下文“spring.root”时出错: 在容器中找不到持久性异常翻译器。不能 执行异常翻译。]
如果我理解得很好,这意味着引发了一个异常,并且 Spring.Net 不知道如何映射/处理它……对吗?
假设它来自 NHibernate,并且正如在与 NHibernate 集成相关的section 44.3.3 from the SpringFramework documentation 中解释的那样,我在我的映射中添加了一个 ExceptionTranslationProcessor...
<object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/>
...但它似乎没有做任何事情,我不知道在哪里进一步寻找。有人有绝妙的想法或提示吗?
提前致谢!
以下是一些数据供参考:
在 web.config 文件中,我添加了 spring section group 和对 xml 定义文件的引用:
<configuration>
<!-- Snip -->
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.MvcContextHandler, Spring.Web.Mvc3"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="file://~/Config/controllers.xml"/>
<resource uri="assembly://Service/Service.Config/Service.xml"/>
<resource uri="assembly://Persistence.Hibernate/Persistence.Hibernate.Config/Persistence.xml"/>
</context>
</spring>
<!-- Snip -->
</configuration>
我在 Persistence.xml 文件中添加的PersistenceExceptionTranslationPostProcessor。出于想法,我也尝试将其添加到其他 xml,但它没有做任何事情。
【问题讨论】:
标签: .net asp.net-mvc nhibernate spring.net