【发布时间】:2015-02-25 11:31:00
【问题描述】:
我正在尝试编写一个采用 twitter 搜索流的应用程序。我的 pom.xml 看起来像这样:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>co.edureka</groupId>
<artifactId>Spring_Integration_Module_Examples</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-twitter</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
</dependencies>
</project>
我还有以下 si-components 配置代码:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xmlns:int-twitter="http://www.springframework.org/schema/integration/twitter"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/integration/twitter http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd">
<int-twitter:search-inbound-channel-adapter
query="#springintegration" channel="inboundTweets">
<int:poller fixed-rate="5000" max-messages-per-poll="3" />
</int-twitter:search-inbound-channel-adapter>
<int:transformer input-channel="inboundTweets"
output-channel="tweetsText" expression="payload.getText()" />
<int-file:outbound-channel-adapter channel="tweetsText"
id="consumer-file-adapter"
directory="file:C:\\Users\\sagio\\Documents\\workspace-sts-3.6.3.RELEASE\\tweeterStream\\data" />
<bean id="twitterTemplate" class="org.springframework.social.twitter.api.impl.TwitterTemplate">
<constructor-arg value=.... />
<constructor-arg value=.... />
<constructor-arg value=.... />
<constructor-arg value=.... />
</bean>
<int:channel id="inboundTweets" />
<int:channel id="tweetsText" />
</beans>
当我尝试运行它时,出现以下异常: 配置问题:找不到 XML 模式命名空间的 Spring NamespaceHandler [http://www.springframework.org/schema/integration/twitter]
这个问题的正确配置是什么?
【问题讨论】:
-
您没有
spring-integration-twitter依赖项。同时补充一点,我强烈建议迁移到 Spring Integration 的 4.x 分支,因为它可以更好地支持 Spring 4。