2014-12-29 83 views
1

我正在嘗試編寫一個需要twitter搜索流的應用程序。我的pom.xml看起來是這樣的:無法找到XML模式名稱空間的Spring NamespaceHandler [http://www.springframework.org/schema/integration/twitter]

<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-組件配置代碼:

<?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]

什麼是此p的正確配置roblem?

+1

您沒有'spring-integration-twitter'依賴關係。同時,我強烈建議遷移到Spring Integration的4.x分支,因爲它更好地支持Spring 4。 –

回答

1

在您的依賴關係列表中,您缺少spring-integration-twitter依賴關係。

<dependency> 
    <groupId>org.springframework.integration</groupId> 
    <artifactId>spring-integration-core</artifactId> 
    <version>4.1.1.RELEASE</version> 
</dependency> 

爲使用Spring 4.x的功能更好,然後3.X分支我建議升級到Spring集成的最新版本。

<?xml version="1.0" encoding="UTF-8"?> 
<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> 

    <properties> 
     <spring.version>4.1.3.RELEASE</spring.version> 
     <spring-integration.version>4.1.1.RELEASE</spring-integration.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.integration</groupId> 
      <artifactId>spring-integration-core</artifactId> 
      <version>${spring-integration.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.integration</groupId> 
      <artifactId>spring-integration-twitter</artifactId> 
      <version>${spring-integration.version}</version> 
     </dependency> 
    </dependencies> 
</project> 

spring-corespring-beans依賴性添加spring-context依賴性時已經包含。

或者甚至更好,您可能想使用Spring IO Platform來對齊所有版本。

<?xml version="1.0" encoding="UTF-8"?> 
<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-context</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.integration</groupId> 
      <artifactId>spring-integration-core</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.integration</groupId> 
      <artifactId>spring-integration-twitter</artifactId> 
     </dependency> 
    </dependencies> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>io.spring.platform</groupId> 
       <artifactId>platform-bom</artifactId> 
       <version>1.1.0.RELEASE</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
</project> 
相關問題