Spring 集成 - Spring 示例配置命名空间问题

Spring Integration - Spring example config namespace issue

问题: 在我的 spring 配置文件中获取元素的命名空间错误。

"Unable to locate Spring NamespaceHandler for element "模式 namcespace 的 int-ws:hyeader-enricher'http://www.springframework.org/schema/integration/ws '

描述: 尝试在 Spring 集成示例项目中创建来自 spring 网站的简单 spring sts spring 使用 Maven 的项目。

我没有在示例目录中找到这个项目,以便与我的项目进行比较。

http://projects.spring.io/spring-integration/

Spring Bean 配置文件

<?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:context="http://www.springframework.org/schema/context"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-http="http://www.springframework.org/schema/integration/http"
    xmlns:int-ws="http://www.springframework.org/schema/integration/ws"
    xmlns:int-xml="http://www.springframework.org/schema/integration/xml"
    xsi:schemaLocation="http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
        http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws.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
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd">


<!-- Simple Service -->

<int:gateway id="simpleGateway"
    service-interface="foo.TempConverter"
    default-request-channel="simpleExpression" />

<int:service-activator id="expressionConverter"
    input-channel="simpleExpression"
    expression="(payload - 32) / 9 * 5"/>

<!-- Web Service -->

<int:gateway id="wsGateway" service-interface="foo.TempConverter"
    default-request-channel="viaWebService" />

<int:chain id="wsChain" input-channel="viaWebService">
    <int:transformer
       expression="'&lt;FahrenheitToCelsius xmlns=''http://www.w3schools.com/webservices/''&gt;&lt;Fahrenheit&gt;XXX&lt;/Fahrenheit&gt;&lt;/FahrenheitToCelsius&gt;'.replace('XXX', payload.toString())" />
    <int-ws:header-enricher>
        <int-ws:soap-action value="http://www.w3schools.com/webservices/FahrenheitToCelsius"/>
    </int-ws:header-enricher>
    <int-ws:outbound-gateway
        uri="http://www.w3schools.com/webservices/tempconvert.asmx"/>
    <int-xml:xpath-transformer
        xpath-expression="/*[local-name()='FahrenheitToCelsiusResponse']/*[local-name()='FahrenheitToCelsiusResult']"/>
</int:chain>

</beans>

更新 - 解决方案 我必须添加该网站上未列出的以下依赖项。我将其添加到 POM 文件中。

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-ws</artifactId>
    <version>4.1.6.RELEASE</version>

</dependency>
<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-xml</artifactId>
    <version>4.1.6.RELEASE</version>
</dependency>

Spring XML 配置命名空间在运行时需要命名空间处理程序(META-INF/spring.handlers class 路径资源,通常在 class 路径上的 JAR 中,提名处理程序 classes).

Spring 在运行时给出此消息的原因是尚未为该 XML 元素注册名称空间处理程序。最可能的原因是 spring-integration-ws.jar(或者可能是必需的依赖项)在运行时不在 class 路径上。