Events 事件:负载表达式为的入站通道适配器无法解析bean

Events 事件:负载表达式为的入站通道适配器无法解析bean,events,spring-integration,Events,Spring Integration,我正在尝试将event:inbound channel adapter用作ApplicationEventListener来捕获ContextRefreshedEvent,以便动态启动file:inbound channel adapter,如: <file:inbound-channel-adapter id="filesIn" auto-startup="false" directory="${input.location}" channel="fileInChannel"&g

我正在尝试将event:inbound channel adapter用作ApplicationEventListener来捕获ContextRefreshedEvent,以便动态启动file:inbound channel adapter,如:

<file:inbound-channel-adapter id="filesIn" auto-startup="false"
    directory="${input.location}" channel="fileInChannel">
    <integration:poller ref="filesInPoller" />
</file:inbound-channel-adapter>


<event:inbound-channel-adapter id='appStarter' channel="nullChannel"                                    
                  error-channel="errorChannel" 
                  event-types="org.springframework.context.event.ContextRefreshedEvent"
                  payload-expression="@filesIn.start()"/>
我认为file:inbound通道适配器能够以这种方式启动,对吗


谢谢

您使用的是哪个版本的Spring Integration?在3.0中,该适配器添加了引用bean@filesIn的功能

如果您使用的是2.2或更低版本,请升级到当前版本或至少3.0.4

在任何情况下,您都不能只将该命令发送到nullChannel,它的计算结果将为null,并且您不能拥有null有效负载;您必须将'@filesIn.start'发送到一个服务器

编辑:


或者,@filesIn.start==null?“foo':“bar”将把foo发送到空频道。

谢谢,我使用的是旧版本2.2,将升级。对于空通道,无论是否转到空通道,SpEL有效负载表达式都不会进行计算吗?我认为这应该启动适配器/polling.Doh中的文件——当然;你是对的;但它将失败,因为您无法创建具有空值的有效负载,这是我们将尝试发送到nullChannel的内容。因此,您应该使用有效负载表达式='@filesIn.start'注意并将其发送到。这将起作用:@filesIn.start==nullfoo':'bar'会将foo发送到空频道。太好了;在这种情况下,习惯上接受答案;谢谢
Exception in thread "main" org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): No bean resolver registered in the context to resolve access to bean 'filesIn'
at org.springframework.expression.spel.ast.BeanReference.getValueInternal(BeanReference.java:45)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:49)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:82)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:72)
at org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer.sendEventAsMessage(ApplicationEventListeningMessageProducer.java:113)
at org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer.onApplicationEvent(ApplicationEventListeningMessageProducer.java:91)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)