我们使用 JOSSO 框架进行单点登录。在 Spring 2.5.6 中可以正常工作。似乎 Spring 3 中引入了严格的 XML 模式验证,JOSSO XSD 已经很长时间没有更新了,因此我们在服务器启动过程中遇到错误。有没有办法在 Spring 3 中禁用架构验证(可能使其工作类似于 2.5.6)..
最佳答案
我还没有尝试过,但是 GenericXmlApplicationContext 有一个 setValidating(boolean validating) 方法。
我相信您可以使用此方法来停用验证:
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.setValidating(false);
context.load("myResource.xml", "otherResource.xml");
context.refresh();
https://jira.springframework.org/browse/SPR-5014
如果您在Web应用程序中使用spring,那么设置验证参数会更加困难。
我能想到的一种方法是,基于 ContextLoader 使用 web.xml 上下文参数“contextClass
”来指定上下文类(默认为:org.springframework.web.context .support.XmlWebApplicationContext
)。
- @参见: org.springframework.web.context.ContextLoader
- @参见: org.springframework.web.context.ContextLoader#defineContextClass(ServletContext)
也许您可以创建禁用验证的 XmlWebApplicationContext 子类,并使用“contextClass
”参数来加载此类而不是 XmlWebApplicationContext。
关于java - 在 Spring 3 中禁用架构验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4160104/