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" />
答案 0 :(得分:1)
集成启动器只会引入spring-integration-core
jar,以避免你不需要的jar的类路径膨胀;你需要添加
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-ip</artifactId>
</dependency>
Boot / Maven将引入正确的版本以匹配核心。