我有一個activemq代理,我想將其配置拆分爲多個文件。我想準備一個單獨的配置文件,它會自動生成,並且只包含隊列的定義。將activemq代理配置拆分爲多個文件
文件1:activemq.xml中
<beans ...>
<broker ...>
</broker>
</beans>
文件2:queues.xml
<beans ...>
<broker ...>
<destinations>
<queue physicalName="q1"/>
</destinations>
</broker>
</beans>
我試着使用:
春進口:
<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.
任何想法?提前致謝。
我現在知道爲什麼實體方法不起作用。我使用基於XSD的Spring配置文件來配置ActiveMQ代理,並且當我添加實體定義時,它切換到DTD驗證而不是XSD,這就是爲什麼它抱怨元素bean沒有被定義。所以實體的定義是正確的,但DTD的使用是有問題的,所以這個解決方案是一個死路。 – rattaman