首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法为XML架构命名空间[http://www.springframework.org/schema/integration/twitter]定位NamespaceHandler

无法为XML架构命名空间[http://www.springframework.org/schema/integration/twitter]定位NamespaceHandler
EN

Stack Overflow用户
提问于 2014-12-29 09:17:00
回答 1查看 3.4K关注 0票数 1

我正在尝试编写一个应用程序,它使用twitter搜索流。我的pom.xml看起来是这样的:

代码语言:javascript
复制
<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组件配置代码:

代码语言:javascript
复制
<?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命名空间定位NamespaceHandler

这个问题的正确配置是什么?

EN

回答 1

Stack Overflow用户

发布于 2014-12-29 09:42:47

在依赖项列表中,您缺少了spring-integration-twitter依赖项。

代码语言:javascript
复制
<dependency>  
    <groupId>org.springframework.integration</groupId>  
    <artifactId>spring-integration-core</artifactId>  
    <version>4.1.1.RELEASE</version>  
</dependency>  

我建议升级到的最新版本,因为它比3.x分支更好地使用了Spring4.x特性。

代码语言:javascript
复制
<?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-core依赖项时,已经包含了spring-contextspring-context依赖项。

或者更好的是,您可能希望使用弹簧IO平台对齐所有版本。

代码语言:javascript
复制
<?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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27686167

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档