我是春季一体化的初学者。我在Spring引导中编写了这段代码,它引发了异常:“名为'messagesource'的bean应该是'org.springframework.context.messagesource'类型,但实际上是'org.springframework.integration.file.filereadingmessagesource'类型。”
代码:
@Configuration
/*@EnableIntegration annotation designates this class as a Spring Integration configuration.*/
@EnableIntegration
public class SIConfig {
@Bean
public MessageChannel channel() {
return new DirectChannel();
}
//bydefault name of method
@Bean
public MessageSource messageSource() {
FileReadingMessageSource ms= new FileReadingMessageSource();
ms.setDirectory(new File("C:\\Users\\payal\\Pictures"));
ms.setFilter(new SimplePatternFileListFilter("*.mp4"));
return ms;
}
@Bean
public MessageHandler handler() {
FileWritingMessageHandler handler= new FileWritingMessageHandler(new File("C:\\Users\\payal\\Documents\\batch7"));
handler.setFileExistsMode(FileExistsMode.IGNORE);
handler.setExpectReply(false);
return handler;
}
@Bean
public IntegrationFlow flow() {
return IntegrationFlows.from(messageSource(), configurer -> configurer.poller(Pollers.fixedDelay(10000)))
.channel(channel())
.handle(handler()).get();
}
}
由于使用boot,版本将自动管理
上传代码n github也:
https://github.com/LearningNewTechnology/SpringIntegrationOne
任何帮助都将不胜感激。