Spring TCP支持-获取异常“类型为AbstractServerConnectionFactory的没有合格的Bean"; [英] Spring TCP Support - Getting Exception "No qualifying bean of type AbstractServerConnectionFactory"

查看:98
本文介绍了Spring TCP支持-获取异常“类型为AbstractServerConnectionFactory的没有合格的Bean";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Spring Integration和Spring TCP支持的新手.我正在尝试启动

I am new to Spring Integration and Spring TCP support. I am trying to start a TCP client that

  1. 连接到serverSocket. ServerSocket位于端口5678上的localhost中
  2. 客户端将消息发送到服务器并收到响应.

但是在运行spring基本示例时出现以下错误.

But I am getting the following error while running the spring basic samples.

我对%spring-samples%/basic/tcp-client-server.xml代码进行了更改.更改是我在 tcpClientServerDemo-context.xml 中注释了服务器端.

I have made a change in the %spring-samples%/basic/tcp-client-server.xml code. Change is that I have commented out the Server side in tcpClientServerDemo-context.xml .

以下是更改.

    <?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 />

    <!-- Client side -->

    <int:gateway id="gw"
        service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"
        default-request-channel="input" />

    <int-ip:tcp-connection-factory id="client"
        type="client"
        host="localhost"
        port="5678"
        single-use="true"
        so-timeout="10000"/>

    <int:channel id="input" />

    <int-ip:tcp-outbound-gateway id="outGateway"
        request-channel="input"
        reply-channel="clientBytes2StringChannel"
        connection-factory="client"
        request-timeout="10000"
        reply-timeout="10000"/>

    <int:object-to-string-transformer id="clientBytes2String"
        input-channel="clientBytes2StringChannel" />


    <!-- Server side ${availableServerSocket}-->
<!--
    <int-ip:tcp-connection-factory id="crLfServer"
        type="server"
        port="5678"/>

    <int-ip:tcp-inbound-gateway id="gatewayCrLf"
        connection-factory="crLfServer"
        request-channel="serverBytes2StringChannel"
        error-channel="errorChannel"/>

    <int:channel id="toSA" />

    <int:service-activator input-channel="toSA"
        ref="echoService"
        method="test"/>

    <bean id="echoService"
        class="org.springframework.integration.samples.tcpclientserver.EchoService" />

    <int:object-to-string-transformer id="serverBytes2String"
        input-channel="serverBytes2StringChannel"
        output-channel="toSA"/>
-->
    <int:transformer id="errorHandler"
        input-channel="errorChannel"
        expression="payload.failedMessage.payload + ':' + payload.cause.message"/>

</beans>

进行此更改后,出现以下错误.

After this change I am getting the following error.

Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory] is defined
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:372)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:332)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1063)
    at org.springframework.integration.samples.tcpclientserver.Main.main(Main.java:77)

我能知道我在想什么,为什么我不应该在想它.

Can I know what I am missing and why I should not be missing it.

另一方面,当我仅运行ServerSocket时,它工作正常.我正在启用服务器端的情况下运行相同的Main方法,但客户端在tcpClientSererDemoContext.xml中进行了注释.以下是serverSocket侦听输入的xml配置.我已经通过Telnet连接并在EchoService.java中将其作为服务激活器进行控制,从而对此进行了测试.

Additionally on the other hand, It works fine when I am running only the ServerSocket. I am running the same Main method with server side enabled but client side commented in tcpClientSererDemoContext.xml. Following is the xml configuration for the serverSocket listening for inputs. And I have tested this by connecting through Telnet and getting control in EchoService.java as a service-activator.

<?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 />

    <!-- Client side -->

<!--    <int:gateway id="gw"
        service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"
        default-request-channel="input" />

    <int-ip:tcp-connection-factory id="client"
        type="client"
        host="localhost"
        port="${availableServerSocket}"
        single-use="true"
        so-timeout="10000"/>

    <int:channel id="input" />

    <int-ip:tcp-outbound-gateway id="outGateway"
        request-channel="input"
        reply-channel="clientBytes2StringChannel"
        connection-factory="client"
        request-timeout="10000"
        reply-timeout="10000"/> -->

    <!-- int:object-to-string-transformer id="clientBytes2String"
        input-channel="clientBytes2StringChannel" 
        output-channel="clientInboundStringChannel"/-->

    <!-- Server side ${availableServerSocket} -->

    <int-ip:tcp-connection-factory id="crLfServer"
        type="server"
        port="5678"/>

    <int-ip:tcp-inbound-gateway id="gatewayCrLf"
        connection-factory="crLfServer"
        request-channel="serverBytes2StringChannel"
        error-channel="errorChannel"/>

    <int:channel id="toSA" />

    <int:service-activator input-channel="toSA"
        ref="echoService"
        method="test"/>

    <bean id="echoService"
        class="org.springframework.integration.samples.tcpclientserver.EchoService" />

    <int:object-to-string-transformer id="serverBytes2String"
        input-channel="serverBytes2StringChannel"
        output-channel="toSA"/>

    <int:transformer id="errorHandler"
        input-channel="errorChannel"
        expression="payload.failedMessage.payload + ':' + payload.cause.message"/>

</beans>

推荐答案

已解决.问题在于注释服务器请求,因为服务器套接字在上下文文件中被注释掉了.

Resolved. Issue was to comment server requests as the server socket was commented out in context file.

这篇关于Spring TCP支持-获取异常“类型为AbstractServerConnectionFactory的没有合格的Bean";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆