2012-12-17 101 views
0

我正在嘗試an example。在這個例子中,它提到像使用彈簧集成2.0.3,但我得到了一個空指針緩存,並解決它我跟着什麼是mentioned here。但是如果我使用spring-integration 2.1,那麼我認爲它需要spring 3.0。使用Spring集成從imap讀取電子郵件集成不起作用

問題: 是否有可能使Spring版本2.5和彈簧集成使用從imap讀取電子郵件?

以下是我的項目設置Maven依賴:

彈簧component.xml文件

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:mail="http://www.springframework.org/schema/integration/mail" 
xmlns:int="http://www.springframework.org/schema/integration" 
xmlns:util="http://www.springframework.org/schema/util" 
xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd 
    http://www.springframework.org/schema/integration/mail 
    http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.1.xsd 
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-2.0.xsd"> 


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

<mail:inbound-channel-adapter id="imapAdapter" 
            store-uri="imaps://<username>:<password>@imap.googlemail.com:993/INBOX"          
            channel="recieveEmailChannel"           
            should-delete-messages="false" 
            should-mark-messages-as-read="true"          
            auto-startup="true" 
            java-mail-properties="javaMailProperties"> 
    <int:poller fixed-delay="5" time-unit="SECONDS"/> 
</mail:inbound-channel-adapter> 

<int:channel id="recieveEmailChannel">   
    <int:interceptors> 
     <int:wire-tap channel="logger"/> 
    </int:interceptors> 
</int:channel> 

<int:logging-channel-adapter id="logger" level="DEBUG"/> 

<int:service-activator input-channel="recieveEmailChannel" ref="emailReceiverService" method="receive"/> 

<bean id="emailReceiverService" class="com.mycompany.DefaultEmailReceiverUtilService"> 
</bean> 

EmailNotificationTest.java

public class EmailNotificationTest extends 
    AbstractDependencyInjectionSpringContextTests 

{ 

public static final String SOURCE_VERSION_ID = "$Id$"; 

    //Who ever wants to run this testcase ,Please uncomment this method 
    protected String[] getConfigLocations() 
    { 
     return new String[] 
     { "classpath:META-INF/spring/component.xml" }; 
    } 

public void testSimpleEmailNotification() 
{ 

} 
} 

如果我跑我的testcase我收到以下例外情況:

org.springframework.beans.factory.BeanDefinitionStoreException:意外的異常從類路徑資源解析XML文檔[META-INF/spring/component.xml];嵌套的異常是java.lang.NoClassDefFoundError:org/springframework/scheduling/support/PeriodicTrigger at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420) at org.springframework.beans.factory。 xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) 處org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) ( AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionRea der.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) 在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212) 在org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:198) 在org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:179) 在org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:158) 在org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests。 java:105) at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:87)

回答

1

我沒有找到簡單的Spring Integration - > Spring版本表。這裏是你可以做什麼:

你會立即看到哪個Spring版本是必需的。例如,使用Spring Integration 2.0.0,你會發現它依賴於Spring 3.0.5。

+0

謝謝,與Spring core 2.5匹配的版本是Spring集成1.0.4.RELEASE。如果我使用1.0.4,我希望它不會引起任何問題。 – Mahendran