XmlApplicationContext:有没有办法立即知道所有配置问题?
XmlApplicationContext 在第一个与类定义不匹配的 XML 定义上返回异常。有没有办法获取 XML 中所有问题的列表?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
XmlApplicationContext 在第一个与类定义不匹配的 XML 定义上返回异常。有没有办法获取 XML 中所有问题的列表?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
不,没有这样的选择。如果容器遇到错误,那么它的依赖关系就会被破坏,并且不知道这将如何影响配置的其余部分。最安全的事情就是当场失败。
在为 Spring.NET 制作 xml 配置时遇到问题是很常见的。您输错了类名、属性名或构造函数类型,并在运行(或集成测试)应用程序时找出答案。你修复它,再次运行它,却发现你在下一行犯了类似的错误。这可能会令人沮丧,所以我完全理解你的问题来自哪里。
您可以采取一些措施来最大限度地减少 xml 配置中的错误:
我建议两者都做。我认为安装插件也会安装 xsd 文件。
您还可以考虑将(部分)配置切换到 Spring.NET 的 CodeConfig,但那就是超出了这个问题的范围。
No there isn't such an option afaik. If the containers encounters an error, then it has got a broken dependency and has got no idea how this would effect the remainder of the configuration. Safest thing is to fail right then and there.
It is very common to encounter problems when crafting xml configuration for Spring.NET. You mistype a class name, property name or constructor type and find out when you run (or integration-test) your application. You fix it, run it again, only to find out you made a similar error on the next line. This can get frustrating, so I fully understand where your question comes from.
There are a few things you can do to minimize making errors in your xml configuration:
I recommend doing both. I think installing the add in also installs the xsd files.
You can also consider switching (parts of) you configuration to Spring.NET's CodeConfig, but that's beyond the scope of this question.