xml - 将 activemq 代理配置拆分为多个文件

标签 xml spring configuration activemq broker

我有一个 activemq 代理,我想将其配置拆分为多个文件。我想准备一个单独的配置文件,它将自动生成并且只包含队列的定义。

文件 1:activemq.xml

<beans ...>
  <broker ...>

  </broker>
</beans>

文件 2:queues.xml

<beans ...>
  <broker ...>
    <destinations>
      <queue physicalName="q1"/>
    </destinations>
  </broker>
</beans>

我尝试使用:

Spring 导入:

<import resource="queues.xml"/>

但是得到了

ERROR: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#1' defined in class path resource [queues.xml]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.apache.activemq:type=Broker,brokerName=localhost org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#1' defined in class path resource [queues.xml]: Invocation of init method failed; nested exception is javax.management.InstanceAlreadyExistsException: org.apache.activemq:type=Broker,brokerName=localhost

XInclude:

activemq.xml:

<beans ...
  xmlns:xi="http://www.w3.org/2001/XInclude"
>
  <broker ...>
    <xi:include href="queues.xml" parse="xml"/>
  </broker>

</beans>

但是得到了

ERROR: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 142 in XML > document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 142; columnNumber: 45; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'xi:include'. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 142 in XML document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 142; columnNumber: 45; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'xi:include'.

Xml 实体 activemq.xml

<!DOCTYPE beans [
<!ENTITY queues SYSTEM "queues.xml">
]>
<beans ...>
  <broker ...>
    &queues;
  </broker>
</beans>

但是得到了

ERROR: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 28 in XML document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 28; columnNumber: 3; Element type "beans" must be declared. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 28 in XML document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 28; columnNumber: 3; Element type "beans" must be declared.

有什么想法吗?提前致谢。

最佳答案

我在 activemq 论坛上问过,有人在那里发布了一个解决方案。这是一个答案 solution at activemq forum .您可以使用 XML 实体,但必须禁用 XML 验证,因此您必须从: bin/activemq 启动 'xbean:conf/activemq.xml?validate=false'

关于xml - 将 activemq 代理配置拆分为多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27926238/

相关文章:

java - ImageView 留下不需要的顶部/底部边距/填充

python - 使用python显示xml中元素的内容

java - 如何在不使用数据库中的任何角色表的情况下编写 spring security?

SSL 配置在 Wildfly 26.0.1 中不起作用

eclipse - 将 Hamcrest 集成到 Eclipse 的 JUnit 的推荐方法是什么?

c# - 我应该使用 XML 文件的命名空间来识别其版本吗

c# - 如何使用 Xpath 获取所有节点属性和值?

java - 在 SPring Boot 2.1.1 中扩展 GlobalMethodSecurityConfiguration 时出现错误,指出已定义 "methodSecurityInterceptor"

java - 我可以在spring服务层使用静态变量吗?

configuration - Jenkins:在电子邮件中构建矩阵作业错误?