在看到一些更神秘的错误消息后,我意识到它们可能是由于此处存在虚假 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
工作正常,当你没有 Internet 问题并且 springframework.org 启动等时,这一切都很可爱而且很好。但是,从上面来看,还有:
http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
给出:
"Oops! This link appears to be broken"
确实糟糕。
关于在项目中引用架构的 URI 的最佳做法是什么?
额外的问题:Eclipse 为什么不实时提示断开的链接? (IntelliJ IDEA 做对了吗!?)
最佳答案
Spring 在启动容器时不会通过网络加载模式 - 有一种机制可以嵌入 schemas within the jar files of Spring , Spring 使用这些内置模式来验证 xml。这也适用于所有自定义命名空间。
Eclipse 可能会提示,因为 Eclipse 下载基于架构 URI 的架构,这可能不是通过网络托管的,就像您的情况一样,还有一种方法可以在 Eclipse 首选项中缓存自定义架构。
关于java - XML 架构位置最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4797008/