XML没有获取<camelContext>标记

par*_*eau 4 xml spring apache-camel xml-namespaces

这可能是一个简单的错误配置问题,但我的xml文档拿起我的标签时遇到问题.我收到了错误

"在这一行找到了多个注释: - cvc-complex-type.2.4.c:匹配的通配符是严格的,但是没有找到元素'camelContext'的声明. - 无法找到模式元素'camelContext'的Spring NamespaceHandler命名空间'http://activemq.apache.org/camel/"

但是当我添加命名空间时,我收到以下错误:

在此行找到多个注释: - cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'camelContext'的声明. - schema_reference.4:无法读取模式文档"http://activemq.apache.org/camel/schema/spring/camel-spring.xsd",因为1)找不到文档; 2)文件无法阅读; 3)文档的根元素不是. - 无法找到模式名称空间"http://activemq.apache.org/camel/schema/spring"的元素"camelContext"的Spring NamespaceHandler

任何人都可以帮我弄清楚为什么我会遇到这两个问题?我不是xml或骆驼的专家,所以任何帮助将不胜感激.下面是我的简单xml文档:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
      http://activemq.apache.org/camel/schema/spring     http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">



   <bean id="myrouter"      class="org.apache.camel.example.reportincident.ReportIncidentRoutes"/>



<!-- Camel Configuration -->

 <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
    <routeBuilderRef ref="myrouter"/>


 </camelContext>

</beans>
Run Code Online (Sandbox Code Playgroud)

Cla*_*sen 7

在Camel 1.x中,XML的名称空间是以activemq开头的名称空间,例如

xmlns="http://activemq.apache.org/camel/schema/spring"
Run Code Online (Sandbox Code Playgroud)

在Camel 2.x中,XML的名称空间是纯粹的Camel,例如

http://camel.apache.org/schema/spring
Run Code Online (Sandbox Code Playgroud)

由于Camel 1.x是EOL,我假设你使用的是Camel 2.x. 如果需要,您需要将<camelContext>标记中的命名空间更改为2.x样式.并删除XML文件顶部的旧引用.

  • @ hoshang.varshney有点晚了但你需要将它添加到xsi:schemaLocation属性的beans标签:http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring /camel-spring.xsd. (2认同)