Camel / Spring给出错误:“声明ActiveMQ代理时,元素'代理的前缀代理:代理'未绑定”

时间:2014-06-23 15:11:26

标签: spring apache-camel activemq

我正在尝试使用嵌入式camel activemq代理。当我在Spring文件中包含以下xml时,我得到错误(底部有更完整的堆栈跟踪):

Line 13 in XML document ... is invalid; ... The prefix "broker" for element "broker:broker" is not bound

引用的xml:

<broker:broker useJmx="false" persistent="false" brokerName="localhost">
   <broker:transportConnectors>
      <broker:transportConnector uri="tcp://localhost:61616"/>
   </broker:transportConnectors>
</broker:broker>

此XML取自Camel in Action一书。我(相信我)拥有所有必需的maven依赖项。

更完整的堆栈跟踪:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [META-INF/spring/filecopycontext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 73; The prefix "broker" for element "broker:broker" is not bound.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at ...

2 个答案:

答案 0 :(得分:0)

我明白了。缺少最顶层的标签,是行:xmlns:broker =“http://activemq.apache.org/schema/core”

答案 1 :(得分:0)

您需要指定broker XML命名空间/ xsd ...

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