【发布时间】:2015-08-04 05:19:31
【问题描述】:
我的 camel-server.xml 和 Spring 集成存在某种配置问题。
我创建了一个名为 camel-server.xml 的文件,其中包含 Camel 在使用 SpringBoot 运行部署应用程序时所需的路由、bean 和其他导入语句。
但是,我有一个奇怪的错误提示:
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.camel.CamelContext] is defined: expected single matching bean but found 2: camel-server,camelContext
我真的不明白为什么 Spring 会找到两个 bean,因为我认为我只是声明了一个。请参阅下面的“camel-server.xml”。
<!-- CXF Spring Config -->
<import resource="classpath:META-INF/spring/cxf-server.xml" />
<!-- Bridge Spring property placeholder with Camel, using Archaius as the Source
You must NOT use the <context:property-placeholder> at the same time, only this bridge bean -->
<bean id="properties" class="com.capgemini.archaius.spring.ArchaiusBridgePropertyPlaceholderConfigurer">
<!-- This must come before the locations -->
<property name="ignoreResourceNotFound" value="true" />
<property name="initialDelayMillis" value="1000" />
<property name="delayMillis" value="1000" />
<property name="ignoreDeletesFromSource" value="false" />
<property name="locations">
<list>
<value>classpath:/META-INF/spring/lrit-emsa-asp-activemq.properties</value>
<value>classpath:/META-INF/spring/lrit-emsa-asp-camel.properties</value>
</list>
</property>
</bean>
<!-- CamelContext -->
<camelContext id="camel-server" trace="true" xmlns="http://camel.apache.org/schema/spring">
<camel:jmxAgent id="camel-server-jmx" createConnector="true" connectorPort="9004"/>
<camel:routeBuilder ref="xxxRoute" />
</camelContext>
<!-- Service Activator Spring Beans -->
<!-- All Service Activator spring beans are located in and annotated with @Component -->
<!-- Additionally, these beans have @Profile annotations indicating when they should be enabled. -->
<!-- Those annotated "default" will always be turned on, unless another bean with the same id (value) is turned on. -->
<!-- To enable a profile, add -Dspring.profiles.active="profile, names, here" to the startup command line -->
<context:component-scan base-package="xxx.yyy.zzz.serviceactivator" />
<!-- Spring Boot Starter Bean -->
<bean id="application" class="xxx.yyy.zzz.Application" />
<!-- Routes -->
<bean id="xxxRoute" class="xxx.yyy.zzz.route.XXXRoute"/>
<!-- Transformers -->
<bean id="pollingRequestTransformer" class="xxx.yyy.zzz.bean.pollingrequest.PollingRequestTransformer"/>
我的 CXF Server XML 如下:
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<cxf:cxfEndpoint id="xyzPortType"
address="${xxx.yyy.services.soap.endpoint}"
wsdlURL="src/main/resources/META-INF/wsdl/ASP-DC.wsdl"
serviceClass="xxx.yyy.zzz.asp.wsdl.XyzPortTypeType"
serviceName="xxx:xxxService"
xmlns:xxx="http://yzs.abc.org/XML/xxx/2008">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
<entry key="loggingFeatureEnabled" value="true"/>
</cxf:properties>
</cxf:cxfEndpoint>
【问题讨论】:
-
看起来你有两个骆驼上下文 - 一个在你的 xml 中配置,一个由类似 Spring-boot 骆驼组件 camel.apache.org/spring-boot.html 的东西配置
标签: java xml spring apache-camel