我有一个 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/