Базовый пример использования Spring Integration для копирования файла в другое исключение, вызывающее каталог - PullRequest
0 голосов
/ 09 декабря 2018

Я новичок в Spring Integration.Я написал этот код, который загружается весной и вызывает исключение. «Бин с именем« messageSource », как ожидается, будет иметь тип« 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();
    }

}

Поскольку с помощью загрузки автоматически управляются версии

Загруженный код и в GitHub:

https://github.com/LearningNewTechnology/SpringIntegrationOne

Любая помощь будет очень признательна.

1 Ответ

0 голосов
/ 09 декабря 2018

Измените имя компонента, например,

@Bean
public MessageSource myMessageSource() {

Spring Framework (контекст) имеет другой тип MessageSource, и автоконфигурация Spring Boot создает компонент этого типа с именем messageSource, поэтомубин сталкивается с этим.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...