没有指定密码

时间:2016-04-27 17:16:47

标签: java spring-integration

我正在尝试使用integration访问Gmail帐户。我需要使用Http.inboundGateway。所以添加到

这样的行
.from(Mail.imapIdleAdapter("imaps://"+(Http.inboundGateway(String.format("%s:%s@imap.gmail.com/INBOX", "myEmail", "myPassword"))).toString())

但问题是,在运行时它抱怨

javax.mail.AuthenticationFailedException: failed to connect, no password specified?

正如你所看到的,我已经在我的请求中定义了我的密码,但它无法识别它,我也确定传递是真的

以下是完整的代码:

@Bean                  
    IntegrationFlow processInvoiceFlow() {
      return IntegrationFlows
          .from(Mail.imapIdleAdapter("imaps://"+(Http.inboundGateway(String.format("%s:%s@imap.gmail.com/INBOX", "myEmail", "myPassword"))).toString())
                .selectorExpression("subject matches '.*invoice.*'"))
          .transform("@invoiceProcessor.extractInvoice(payload)")
          .route("#xpath(payload, '//total <= 1800', 'string')", mapping -> mapping
              .subFlowMapping("true", sf -> sf
                  .handle("invoiceProcessor", "processInvoice"))
              .subFlowMapping("false", sf -> sf
                  .handle(System.out::println))
          )
          .get();
    }

重点是,我可以访问没有Http.inboundGateway的帐户 使用:

.from(Mail.imapIdleAdapter(String.format("imaps://%s:%s@imap.gmail.com/INBOX", myEmail, myPassword))

1 个答案:

答案 0 :(得分:1)

你介意解释一下:

  

我需要使用Http.inboundGateway

从另一方面,调用Http.inboundGateway().toString() ...

的奇怪代码是什么

您希望使用该代码到底达到什么目的?是的,它是由Java性质有效的。但逻辑是荒谬的......

你的Mail.imapIdleAdapter(String.format())看起来好多了!

相关问题