Spring integration 我已经尝试将spring集成xml配置转换为java配置。我面临一些问题,我已经在下面讨论过了

Spring integration 我已经尝试将spring集成xml配置转换为java配置。我面临一些问题,我已经在下面讨论过了,spring-integration,Spring Integration,尝试了下面给出的两种方法,但不起作用。我已经给出了我在以下方法中面临的问题。 Xml配置:第一个配置出错: 错误:通过工厂方法实例化Bean失败;嵌套异常为org.springframework.beans.beans实例化异常:未能实例化[org.springframework.integration.mail.Pop3MailReceiver]:工厂方法“Pop3MailReceiver”引发异常;嵌套异常是java.lang.NoClassDefFoundError:javax/mail/

尝试了下面给出的两种方法,但不起作用。我已经给出了我在以下方法中面临的问题。
Xml配置:第一个配置出错:

错误:通过工厂方法实例化Bean失败;嵌套异常为org.springframework.beans.beans实例化异常:未能实例化[org.springframework.integration.mail.Pop3MailReceiver]:工厂方法“Pop3MailReceiver”引发异常;嵌套异常是java.lang.NoClassDefFoundError:javax/mail/Service

问题是无法导入IntegrationFlows、Mail,即使它们在我的maven依赖项中

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.muraai.mail</groupId>
    <artifactId>mail</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
    </parent>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-java-dsl</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-mail</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>

                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

4.0.0
com.muraai.mail
邮件
0.0.1-快照
1.8
org.springframework.boot
spring启动程序父级
1.5.4.1发布
org.springframework.boot
SpringBootStarterWeb
org.springframework.integration
spring集成JavaDSL
org.springframework.integration
spring集成邮件
org.apache.maven.plugins
maven编译器插件
1.8
1.8

正如我从堆栈跟踪中的问题中看到的,它表示没有类定义错误

抛出异常;嵌套异常为java.lang.NoClassDefFoundError:javax/mail/Service


这通常意味着类路径或应用程序加载的位置缺少mail.jar,请检查类路径以查看是否存在所有jar文件

这很好,但如何在此方法中指定通道。你能检查我的第二个配置吗?你能分享第二个配置中出现的错误的堆栈跟踪吗
@Configuration
@EnableIntegration
public class MailConfig {

    @Bean
    public DirectChannel inputChannel() {
        return new DirectChannel();
    }

    private Properties javaMailProperties() {
        Properties javaMailProperties = new Properties();

        javaMailProperties.setProperty("mail.imap.socketFactory.class","javax.net.ssl.SSLSocketFactory");
        javaMailProperties.setProperty("mail.imap.socketFactory.fallback","false");
        javaMailProperties.setProperty("mail.store.protocol","imaps");
        javaMailProperties.setProperty("mail.debug","true");

        return javaMailProperties;
    }

    @Bean
    public Pop3MailReceiver pop3MailReceiver() {
        Pop3MailReceiver receiver = new Pop3MailReceiver("pop3://[un]:[pwd]@pop.gmail.com/INBOX");
        receiver.setJavaMailProperties(javaMailProperties());
        receiver.setShouldDeleteMessages(false);
        //receiver.setChannelResolver((DestinationResolver<MessageChannel>) inputChannel());
        return receiver;
    }

}
    @Bean
    public IntegrationFlow pop3MailFlow() {
        return IntegrationFlows
                .from(Mail.pop3InboundAdapter("localhost", "995", "user", "pw")
                .javaMailProperties(p -> p.put("mail.debug", "true")),e -> e.autoStartup(true)
                .poller(Pollers.fixedDelay(60000)))
                .channel(MessageChannels.queue("pop3Channel"))
                .get();
    }
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.muraai.mail</groupId>
    <artifactId>mail</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
    </parent>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-java-dsl</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-mail</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>

                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>