没有互联网连接时,Spring schemaLocation失败

没有互联网连接时,Spring schemaLocation失败,第1张

没有互联网连接时,Spring schemaLocation失败

如果正确配置了名称空间且XSD文件位于类路径中,则无需在schemaLocation URL中使用classpath:协议。

Spring doc“ 注册处理程序和模式 ”显示了应如何完成。

在你的情况下,问题可能出在你的类路径上的spring-context jar不是2.1。这就是将协议更改为类路径的原因:并将特定的2.1 XSD放在类路径中可以解决此问题。

从我所看到的,在spring- * jar中为主XSD定义了2个模式。一次使用版本解析模式URL,一次不使用版本解析模式URL。

例如,请参阅spring-context-3.0.5.RELEASE.jar中spring.schemas内容的这一部分:

http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsdhttp://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsdhttp://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.0.xsd

这意味着(在xsi:schemaLocation中)

http://www.springframework.org/schema/context/spring-context-2.5.xsd 

将针对

org/springframework/context/config/spring-context-2.5.xsd 

在类路径中。

http://www.springframework.org/schema/context/spring-context-3.0.xsd 

要么

http://www.springframework.org/schema/context/spring-context.xsd

将针对

org/springframework/context/config/spring-context-3.0.xsd 

在类路径中。

http://www.springframework.org/schema/context/spring-context-2.1.xsd

未定义,因此Spring将使用schemaLocation中定义的文字URL进行查找。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5109237.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存