Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring TCP支持-获取异常“;没有AbstractServerConnectionFactory类型的合格bean;_Spring_Sockets_Tcp_Client_Integration - Fatal编程技术网

Spring TCP支持-获取异常“;没有AbstractServerConnectionFactory类型的合格bean;

Spring TCP支持-获取异常“;没有AbstractServerConnectionFactory类型的合格bean;,spring,sockets,tcp,client,integration,Spring,Sockets,Tcp,Client,Integration,我不熟悉Spring集成和Spring TCP支持。我正在尝试启动一个TCP客户端 连接到服务器套接字。ServerSocket位于端口5678上的本地主机中 客户端向服务器发送消息并接收响应 但是我在运行spring basic示例时遇到以下错误 我对%spring samples%/basic/tcp-client-server.xml代码进行了更改。变化是我在tcpClientServerDemo context.xml中注释掉了服务器端 以下是变化 <?xml versio

我不熟悉Spring集成和Spring TCP支持。我正在尝试启动一个TCP客户端

  • 连接到服务器套接字。ServerSocket位于端口5678上的本地主机中
  • 客户端向服务器发送消息并接收响应
  • 但是我在运行spring basic示例时遇到以下错误

    我对%spring samples%/basic/tcp-client-server.xml代码进行了更改。变化是我在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>
    
    我能知道我错过了什么,为什么我不应该错过它

    另外,在另一方面,当我只运行ServerSocket时,它工作得很好。我正在运行相同的主方法,启用了服务器端,但客户端在tcpclientserdemocontext.xml中进行了注释。以下是侦听输入的serverSocket的xml配置。我已经通过Telnet连接并在EchoService.java中作为服务激活器获得控制权来测试了这一点

    <?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>
    
    
    
    已解决。问题是在上下文文件中注释掉服务器套接字时注释服务器请求。

    您能发布准确的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="${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>