Spring Integration S3' beanName'一定不能空着

时间:2017-12-19 22:41:18

标签: spring-integration

我正在尝试使用S3入站通道适配器从S3下载文件。这是我的配置:

s3.xml:
<int:chain input-channel="s3ReaderChannel" output-channel="uncompressPayloadChannel">
 <int:service-activator ref="s3Bean" method="generateS3ObjectHash" />
 <int-aws:s3-inbound-channel-adapter 
               bucket="${s3.bucket}"
               session-factory="s3SessionFactory"
               auto-create-local-directory="true"
               auto-startup="false"
               filename-pattern="*.gz"
               local-directory="."
               local-filename-generator-expression="#this"
               temporary-file-suffix=".transffering"
               remote-directory="/remote/mytransfers"
               local-filter="acceptAllFilter"/>
</int:chain>

<bean id="s3SessionFactory" 
class="org.springframework.integration.aws.support.S3SessionFactory"/>




aws-credentials.xml:
<!-- Define global credentials for all the AWS clients -->
<aws-context:context-credentials>
<aws-context:instance-profile-credentials/>
<aws-context:simple-credentials access-key="${aws.accesskey}"
                                secret-key="${aws.secretkey}"/>
</aws-context:context-credentials>

<!-- Define global region -->
<aws-context:context-region region="${aws.region}"/>

当我尝试执行时,我得到了:

Exception in thread "main"` 
`org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected 
exception parsing XML document from file`; nested exception is 
java.lang.IllegalArgumentException: 'beanName' must not be empty
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
...30 more
Caused by: java.lang.IllegalArgumentException: 'beanName' must not be empty
at org.springframework.util.Assert.hasText(Assert.java:181)
at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:58)
at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:46)
at org.springframework.beans.factory.support.BeanDefinitionBuilder.addPropertyReference(BeanDefinitionBuilder.java:226)
at org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser.doParse(AbstractPollingInboundChannelAdapterParser.java:64)
   ...20 more
`

从堆栈跟踪中,AbstractPollingInboundChannelAdapterParser.java:64是关于outputChannel的,我不明白,因为它在链中。

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

是的,入站通道适配器是流程的开始,它根本不能在<chain>中声明。更多的是你有一些混乱,就像你在<int:service-activator>之后宣布它一样。

您必须将<int-aws:s3-inbound-channel-adapter>移到<chain>之外,并记住这一步将成为您流程的开始。

我不确定是什么让你认为错误的方式,但看起来你需要Reference Manual的更多信息。