无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/integration/ip

时间:2017-05-07 15:52:29

标签: java spring spring-integration

你能帮我解决一下吗?我在Spring STS IDE中使用Spring 4.3.8。我得到以下异常:org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/integration/ip] 违规资源:类路径资源[spring-config.xml]

Maven config:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-integration</artifactId>
</dependency>

我的Spring配置是:

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

<context:property-placeholder location="classpath:udp-server.properties" />

<bean id="udpConsumer" class="com.example.udp.UDPConsumer" />

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

<int-ip:udp-inbound-channel-adapter id="udpReceiver"
    channel="inputChannel"
    port="${udp-server.port}"
    pool-size="${udp-server.threads}"
    receive-buffer-size="${udp-server.buffer-size}"
    multicast="false"
    check-length="true"/>

<int:service-activator input-channel="inputChannel"
    ref="udpConsumer" />

<int:poller default="true" fixed-rate="500" />

1 个答案:

答案 0 :(得分:1)

集成启动器只会引入spring-integration-core jar,以避免你不需要的jar的类路径膨胀;你需要添加

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-ip</artifactId>
</dependency>

Boot / Maven将引入正确的版本以匹配核心。