【问题标题】:CamelContext with SpringCamelContext 与 Spring
【发布时间】: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>

【问题讨论】:

标签: java xml spring apache-camel


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 2020-07-09
      • 1970-01-01
      • 2012-12-31
      • 2016-05-07
      相关资源
      最近更新 更多