Spring.Net + NHibernate - “http://www.springframework.net/database:provider”元素未声明
我遇到了一些 Spring 和 NHibernate 问题,似乎没有人能够解决。我使用 NorthWind 项目作为示例。现在我收到此错误:
'MyNamespace.MyClass.MyFunction:
Spring.Objects.Factory.ObjectDefinitionStoreException : Line 6 in XML document from assembly [MyAssembly, Version=0.0.1.0, Culture=neutral, PublicKeyToken=334479e19ddfb52d], resource [MyNamespace.Dao.xml] violates the schema. The 'http://www.springframework.net/database:provider' element is not declared.
----> System.Xml.Schema.XmlSchemaValidationException : The 'http://www.springframework.net/database:provider' element is not declared.'
引用了我的 XML 中的以下位:
<db:provider id="DbProvider"
provider="System.Data.SqlClient"
connectionString="Data Source=MyServer\MyDatabase;Initial Catalog=master;Integrated Security=True"/>
我已包含正确的命名空间,将 xsd 添加到我的项目中,并将解析器添加到我的 App.config 文件中:
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
但
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
</parsers>
</spring>
它没有似乎没有把它捡起来。有什么想法为什么我会收到此错误吗?我读到的所有地方都说错误是因为我没有定义解析器,但我显然已经定义了。
I’m having some Spring and NHibernate issues which nobody seems to be able to resolve. I'm using the NorthWind project as an example to go off of. Right now I’m getting this error:
'MyNamespace.MyClass.MyFunction:
Spring.Objects.Factory.ObjectDefinitionStoreException : Line 6 in XML document from assembly [MyAssembly, Version=0.0.1.0, Culture=neutral, PublicKeyToken=334479e19ddfb52d], resource [MyNamespace.Dao.xml] violates the schema. The 'http://www.springframework.net/database:provider' element is not declared.
----> System.Xml.Schema.XmlSchemaValidationException : The 'http://www.springframework.net/database:provider' element is not declared.'
The refers to the following bit in my XML:
<db:provider id="DbProvider"
provider="System.Data.SqlClient"
connectionString="Data Source=MyServer\MyDatabase;Initial Catalog=master;Integrated Security=True"/>
I’ve included the correct namespace, added the xsd’s to my project, and added the parser to my App.config file:
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
and
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
</parsers>
</spring>
But it doesn’t seem to be picking it up. Any ideas why I’m getting this error? Everywhere I read says the error is because I haven’t defined the parser, but I obviously have.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它根本不加载我的 App.config 文件,因此它从未加载解析器。
我添加了以下代码:
并且它有效。
It isn't loading my App.config file at all, so it was never loading the parser.
I added the following code:
and it worked.