XML模式架构位置最佳实践

4

在看到一些更加晦涩的错误信息后,我意识到这可能是由于此处存在虚假URI而导致的:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint"    
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://activemq.apache.org/camel/schema/spring
        http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
        http://activemq.apache.org/camel/schema/cxfEndpoint
        http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
        http://cxf.apache.org/jaxws 
        http://cxf.apache.org/schemas/jaxws.xsd
        ">

参考在线模式是一个好的实践方法吗?

例如,从上面的例子可以看出:

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

这个链接在没有网络问题且springframework.org正常运行时可以使用,但是从上面的内容可以看出,还有其他的链接:

http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd

这将会得到:

"Oops! This link appears to be broken"

确实是个小错误。

在项目中涉及到引用模式的URI时,有哪些最佳实践呢?

奖励问题:为什么Eclipse不会实时抱怨损坏的链接?(IntelliJ IDEA做得对吗!?)


这些 URI 是否指向模式是 SPOF 吗? - Gugussee
2个回答

3
Spring在启动容器时不会通过网络加载模式 - 它有一种机制将模式嵌入Spring的jar文件中,并且Spring使用这些内置模式来验证xml。对于所有自定义命名空间都适用。
Eclipse可能会抱怨,因为Eclipse基于架构URI下载模式,而这些模式可能没有托管在网络上,例如在您的情况下,还有一种方法可以在Eclipse首选项中缓存自定义模式。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接