错误配置:找不到 XML 模式命名空间的 Spring NamespaceHandler

Posted

技术标签:

【中文标题】错误配置:找不到 XML 模式命名空间的 Spring NamespaceHandler【英文标题】:Error Configuration : Unable to locate Spring NamespaceHandler for XML schema namespace 【发布时间】:2018-04-28 18:40:48 【问题描述】:

我在 Spring 服务应用程序中遇到错误。请任何人帮助我。由于以下错误,上下文初始化失败。

错误

上下文初始化失败 rg.springframework.beans.factory.parsing.BeanDefinitionParsingException: 配置问题:找不到 XML 模式命名空间的 Spring NamespaceHandler [http://www.springframework.org/schem/integration/ftp] 弹簧配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:int="http://www.springframework.org/schema/integration"
   xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
   xsi:schemaLocation="http://www.springframework.org/schema/integration/ftp 
http://www.springframework.org/schema/integration/ftp/spring-integration-
ftp.xsd
            http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="test.rebex.net"/>
    <property name="port" value="21"/>
    <property name="username" value="demo"/>
    <property name="password" value="password"/>
</bean>

<int-ftp:inbound-channel-adapter id="ftpInbound"
            channel="ftpChannel"
            session-factory="ftpClientFactory"
            filename-pattern="readme.txt"
            auto-create-local-directory="true"
            delete-remote-files="false"
            remote-directory="/pub/example/"
            local-directory="C:/Users/TOOW10/temp/">
        <int:poller fixed-rate="1000"/>
</int-ftp:inbound-channel-adapter>

<int:channel id="ftpChannel">
    <int:queue/>
</int:channel>

pom.xml

    <dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.25.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.annotation/jsr250-api -->
    <!-- https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305 -->
    <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>jsr305</artifactId>
        <version>2.0.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.json/json -->
    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.9</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>$spring.version</version>
    </dependency>
    <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>4.1.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.hybris.datahub</groupId>
        <artifactId>datahub-extension-sdk</artifactId>
        <version>6.5.0.0-RC3</version>
        <scope>provided</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.integration/spring-integration-ftp -->
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-ftp</artifactId>
        <version>4.1.0.RELEASE</version>
    </dependency>


</dependencies>
<properties>
    <spring.version>4.3.3.RELEASE</spring.version>
</properties>

【问题讨论】:

【参考方案1】:

您似乎在integration-ftp.xsd 之间有了新的一行。我得到一个不同的错误,但它应该被修复。

如果这不是问题,则说明您的类路径有问题。仔细检查 maven 是否已将 spring-integration-ftp jar 放在类路径中。

【讨论】:

以上是关于错误配置:找不到 XML 模式命名空间的 Spring NamespaceHandler的主要内容,如果未能解决你的问题,请参考以下文章

找不到 XML 模式命名空间 Application-Context 的 Spring NamespaceHandler

我在Tomcat部署项目,报500错误,说命名空间找不到,我运行正常的项目呀

找不到 XML 模式命名空间的 Spring NamespaceHandler [http://www.springframework.org/schema/webflow]

Symfony 错误:在链配置的命名空间 App\Entity 中找不到类 xxx [重复]

Zend Framework 2 + Doctrine ODM,“在链配置的命名空间中找不到类”错误?

XML XSD 错误:org.xml.sax.SAXParseException:s4s-elt-schema-ns:元素“配置”的命名空间必须来自模式命名空间