Spring integration 在出站通道适配器spring集成中修改输出目录

Spring integration 在出站通道适配器spring集成中修改输出目录,spring-integration,Spring Integration,下面是我对文件轮询功能的配置xml。有时我必须更改输出目录 <int-file:inbound-channel-adapter id="filesIn" directory="file:${paths.root}" channel="abc" > <int:poller id="poller" fixed-delay="5000"/> </int-file:inbound-channel-adapter> <int:ch

下面是我对文件轮询功能的配置xml。有时我必须更改输出目录

<int-file:inbound-channel-adapter id="filesIn" directory="file:${paths.root}" channel="abc" >
        <int:poller id="poller" fixed-delay="5000"/>

    </int-file:inbound-channel-adapter>
    <int:channel id="abc"/>

    <int-file:outbound-channel-adapter channel="abc" id="filesOut" 
    directory-expression="@aPath.getPath()"
    delete-source-files="true" 
    filename-generator ="filenameGenerator"/>

<bean id="filenameGenerator" class="com.dms.util.FileNameGenerator"/>
对于bean:

@Component("outPathBean")
在我的代码中

outPathBean.setPath(newFolder);
我的调试表明该属性的值没有更改。我的问题是,如何在generateFileName方法中或通过任何其他方式修改目录


请帮忙

您尝试使用的常规机制将起作用,因为在计算目录表达式之前调用了文件名生成器

但是,您有两个实例真正定义了
@组件(并且您正在使用组件扫描,您将有两个
GetOutPath
-
aPath
outPathBean
的实例)

表达式正在使用您未更改的实例


您需要注入表达式中使用的同一个bean实例。

谢谢。因此,如果我删除配置文件bean声明,这应该会起作用??OK done!!删除了xml声明,效果很好。如果我删除@component并保留xml声明,会不会发生同样的情况?我不确定是否有权访问Filenamegenerator中的bean..谢谢。删除任何一个都可以。只有一个bean,您甚至不需要更改bean名称。
@Autowired
    private GetOutPath outPathBean;
@Component("outPathBean")
outPathBean.setPath(newFolder);