Java Spring集成:@ServiceActivator不工作

Java Spring集成:@ServiceActivator不工作,java,spring,spring-integration,Java,Spring,Spring Integration,我有以下课程: @Configuration public class SpringIntegrationTest { @Bean public SimpleWebServiceInboundGateway testInboundGateWay (){ SimpleWebServiceInboundGateway simpleWebServiceInboundGateway = new SimpleWebServiceInboundGateway();

我有以下课程:

@Configuration
public class SpringIntegrationTest {

    @Bean
    public SimpleWebServiceInboundGateway testInboundGateWay (){
        SimpleWebServiceInboundGateway simpleWebServiceInboundGateway = new SimpleWebServiceInboundGateway();
        simpleWebServiceInboundGateway.setRequestChannelName("testChannel");
        simpleWebServiceInboundGateway.setReplyChannelName("testChannel2");
        return simpleWebServiceInboundGateway;
    }

    @Bean
    public MessageChannel testChannel() {
        return new DirectChannel();
    }

    @Bean
    public MessageChannel testChannel2() {
        return new DirectChannel();
    }

    @ServiceActivator(inputChannel = "testChannel", outputChannel = "testChannel2")
    public DOMSource foo(DOMSource request) {
        System.out.println("asd");
        return request;
    }

    @Bean
    public EndpointMapping soapActionEndpointMapping(SimpleWebServiceInboundGateway testInboundGateWay ) {
        UriEndpointMapping uriEndpointMapping = new UriEndpointMapping();
        uriEndpointMapping.setUsePath(true);
        uriEndpointMapping.setEndpointMap(createEndpointMapping(testInboundGateWay ));
        return uriEndpointMapping;
    }

    private Map<String, Object> createEndpointMapping(SimpleWebServiceInboundGateway testInboundGateWay ) {
        Map<String, Object> endpointMap = new HashMap<>();
        endpointMap.put("/ws/test", testInboundGateWay );
        return endpointMap;
    }

}
@配置
公共类SpringIntegrationTest{
@豆子
公共SimpleWebServiceInboundGateway testInboundGateWay(){
SimpleWebServiceInboundGateway SimpleWebServiceInboundGateway=新建SimpleWebServiceInboundGateway();
simpleWebServiceInboundGateway.setRequestChannelName(“testChannel”);
simpleWebServiceInboundGateway.setReplyChannel名称(“testChannel2”);
返回simpleWebServiceInboundGateway;
}
@豆子
public MessageChannel testChannel(){
返回新的DirectChannel();
}
@豆子
public MessageChannel testChannel2(){
返回新的DirectChannel();
}
@ServiceActivator(inputChannel=“testChannel”,outputChannel=“testChannel 2”)
公共DOMSource foo(DOMSource请求){
系统输出打印项次(“asd”);
返回请求;
}
@豆子
公共端点映射soapActionEndpointMapping(SimpleWebServiceInboundGateway testInboundGateWay){
UriEndpointMapping UriEndpointMapping=新的UriEndpointMapping();
uriEndpointMapping.setUsePath(true);
setEndpointMap(createEndpointMapping(testInboundGateWay));
返回映射;
}
私有映射createEndpointMapping(SimpleWebServiceInboundGateway testInboundGateWay){
Map endpointMap=newhashmap();
endpointMap.put(“/ws/test”,testInboundGateWay);
返回端点映射;
}
}
即使service activator订阅了“testChannel”,我也会收到以下消息:

o、 s.i.w.SimpleWebServiceInboundGateway-网关发送和接收中发生故障:Dispatcher没有通道“org.springframework.web.context.WebApplicationContext:/MyProject restful API.testChannel”的订户。;嵌套异常为org.springframework.integration.MessageDispatchingException:Dispatcher没有订阅服务器


我做错了什么?

您需要将
@EnableIntegration
添加到一个配置类中。

向testChannel添加一个调度程序可以解决此问题