CamelContext with Spring

时间:2015-05-22 08:55:03

标签: java xml spring apache-camel

我的camel-server.xml和Spring集成存在某种配置问题。

我创建了一个名为camel-server.xml的文件,其中包含Camel在使用SpringBoot部署应用程序时所需的路由,bean和其他import语句。

但是,我有这个奇怪的错误:

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会找到两个豆子,因为我认为我只是在宣布一个豆子。查看我的“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服务器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>

2 个答案:

答案 0 :(得分:1)

就是这样!谢谢你从我的Application类中删除了@EnableAutoConfiguration,它只查看了我的camer-server.xml。

答案 1 :(得分:0)

在Camel项目中使用Jboss fuse Integration,您可以使用现有模板创建spring项目,而无需担心集成问题。