在 Fuse 项目中找不到 Spring bean

Unable to find Spring bean in Fuse Project

我正在使用 Bean 设置 Camel 路线的主体。这适用于 Camel 独立项目。当部署在 JBoss Fuse 上时,找不到 Spring bean。这是蓝图的片段:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
             http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">


    <bean id="personFactory" class="sample.PersonFactory" />
    <bean id="myBean" class="sample.Person" />

    <camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/blueprint" xmlns:order="http://fusesource.com/examples/order/v7">

  <route id="myroute">
    <from uri="timer:foo?repeatCount=1"/>
    <setProperty propertyName="name">
      <constant>John</constant>
    </setProperty>
    <setProperty propertyName="surname">
      <constant>Doe</constant>
    </setProperty>

     <setBody>
      <spel>#{@personFactory.createPerson(properties['name'],properties['surname'])}
      </spel>
    </setBody>

 . . . .
  </route>
</camelContext>


</blueprint>

在 Fuse 上部署时,出现以下异常:

org.apache.camel.ExpressionEvaluationException: org.springframework.expression.spel.SpelEvaluationException: 
EL1057E:(pos 1): No bean resolver registered in the context to resolve access to bean 'personFactory'

有什么帮助吗?

我最近遇到了同样的问题。不幸的是,没有设法使用 spel 解决这个问题并已切换到简单。这对您的情况应该有所帮助:

<simple>${bean:personFactory?method=createPerson(property.name, property.surname)}</simple>