2014-05-23 37 views
1

我创建了一个邮件流用下面的命令-------春天XD - 邮件源配置 - 如何提供密码

stream create --name mailstream --definition "mail --host=imap.gmail.com [email protected] --password=my password | file --dir=/tmp/gmailData" --deploy 

参考 - http://docs.spring.io/spring-xd/docs/1.0.0.BUILD-SNAPSHOT/reference/html/#modules

但在XD-singletone控制台我得到 -

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

如何解决此问题。

而且--password =秘密 - 如何让我的密码不可见或秘密的XD外壳

/shankha

回答

3

你需要逃离“@”和“40%”两个用户名和密码并为gmail指定--port=993。此外,可能不会使用默认设置,因为GMail需要对imap使用SSL,并且也需要配置此设置。

所以,我建议如下(基本上,创建一个新的源模块):

  1. 转到spring-xd-1.0.0.M6\xd\modules\source,使mail文件夹并命名该副本gmail
  2. 围棋的副本spring-xd-1.0.0.M6\xd\modules\source\gmail\config和重命名既mail.propertiesmail.xmlgmail.propertiesgmail.xml分别为
  3. gmail.xml取代的一切:
<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/integration" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:file="http://www.springframework.org/schema/integration/file" 
    xmlns:int-mail="http://www.springframework.org/schema/integration/mail" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:util="http://www.springframework.org/schema/util" 
    xsi:schemaLocation="http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd 
     http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> 
    <channel id="output" /> 

    <int-mail:mail-to-string-transformer 
     charset="${charset}" input-channel="transform" output-channel="output" /> 

    <beans:beans profile="use-polling"> 
     <int-mail:inbound-channel-adapter 
      store-uri="${protocol}://${username:}:${password:}@${host}:${port}/${folder}" 
      channel="transform" should-mark-messages-as-read="${markAsRead}" 
      should-delete-messages="${delete}" java-mail-properties="javaMailProperties"> 
      <poller fixed-delay="${fixedDelay}" time-unit="SECONDS"> 
       <advice-chain> 
        <beans:bean 
         class="org.springframework.xd.dirt.module.support.ThreadContextClassLoaderSetterAdvice" /> 
       </advice-chain> 
      </poller> 
     </int-mail:inbound-channel-adapter> 
    </beans:beans> 

    <beans:beans profile="use-idle"> 
     <int-mail:imap-idle-channel-adapter 
      store-uri="${protocol}://${username:}:${password:}@${host}:${port}/${folder}" 
      channel="transform" auto-startup="true" mail-filter-expression="${expression}" 
      should-mark-messages-as-read="${markAsRead}" 
      should-delete-messages="${delete}" java-mail-properties="javaMailProperties"> 
     </int-mail:imap-idle-channel-adapter> 
    </beans:beans> 

    <beans:beans profile="default"> 
     <util:properties id="javaMailProperties"> 
      <beans:prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</beans:prop> 
      <beans:prop key="mail.imap.socketFactory.fallback">false</beans:prop> 
      <beans:prop key="mail.store.protocol">imaps</beans:prop> 
      <beans:prop key="mail.debug">false</beans:prop> 
     </util:properties> 
    </beans:beans> 
</beans:beans> 

4.在XD壳现在你会使用类似以下内容来创建你的流:

stream create --name myGmailStream --definition "gmail --host=imap.gmail.com --username=yyyyyyyy12%40gmail.com --password=my_password --port=993 | file --dir=/tmp/gmailData" --deploy 

这里,请注意以下几点:

  • 我加入--port=993
  • 用户名含有“%40”而不是“@”
  • s tream与"gmail
  • 开始,如果您的密码包含“@”,你需要替换成“%40”以及

什么我上面做的就是,基本上,创建一个新的自定义模块(源),这是很容易的(关于这个更详细的信息,你可以在documentation找到)。 XD单节点或XD Shell甚至不需要重新启动。试试看,让我知道它是怎么回事。

+0

谢谢你。它的工作原理。但我如何保护我的密码?因为在流创建命令我提供我的密码 - 密码选项。我尝试在config/modules/source/gmail/gmail.properties中配置usrer名称,密码,主机............但它失败....我如何使用属性文件 – user3575226