我正在尝试使用integration访问Gmail帐户。我必须使用Http.inboundGateway。所以添加到行像

.from(Mail.imapIdleAdapter("imaps://"+(Http.inboundGateway(String.format("%s:%[email protected]/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:%[email protected]/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:%[email protected]/INBOX", myEmail, myPassword))

最佳答案

您介意解释一下:


我需要使用Http.inboundGateway




从另一面来看,调用Http.inboundGateway().toString()的奇怪代码是什么...

您到底想用该代码实现什么?是的,它在Java本质上是有效的。但这是荒谬的逻辑...

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

10-06 10:00