我正在尝试一个例子。在示例中,它被提及为使用 spring-integration 2.0.3,但我得到了 NullPointerExcpetion 并且为了解决它,我遵循了这里提到的内容。但是如果我使用 spring-integration 2.1,那么我认为它需要 spring 3.0。
问题: 是否有可能拥有 Spring 2.5 版并使用从 imap 读取电子邮件的 spring-integration?
以下是我项目中设置的maven依赖:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
...
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mail</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
弹簧组件.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()
{
}
}
如果我运行我的测试用例,我会收到以下异常:
org.springframework.beans.factory.BeanDefinitionStoreException:从类路径资源 [META-INF/spring/component.xml] 解析 XML 文档时出现意外异常;嵌套异常是 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420) 中的 java.lang.NoClassDefFoundError: org/springframework/scheduling/support/PeriodicTrigger。 XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java: 143)在 org.springframework.beans.factory.support.AbstractBeanDefinitionReader。