У меня есть агент 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.
Любые идеи? Заранее спасибо.
Теперь я знаю, почему подход сущности не работает. Я использую файлы конфигурации Spring на основе XSD для настройки брокер ActiveMQ, и когда я добавляю определение сущности, он переключается на проверку DTD вместо XSD, и именно поэтому он жалуется на то, что элементные элементы не определены. Таким образом, сущность определяется правильно, но само использование DTD является проблематичным, и поэтому это решение является мертвым. – rattaman