Spring配置之RMI

本文介绍了如何使用Spring框架配置RMI服务。包括服务端的RMI导出配置及客户端的代理工厂配置,确保两端接口一致性和通信端口设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

    <!-- spring rmi服务端配置 -->

    <bean id="cdeskService" class="com.cdesk.service.impl.CDeskService"></bean>
    <bean id="rmiServiceExporter_order" class="org.springframework.remoting.rmi.RmiServiceExporter">
        <property name="service" ref="cdeskService" />
        <!-- 定义服务名 -->
        <property name="serviceName" value="cdesk" />
        <!--接口类名 -->
        <property name="serviceInterface" value="com.cdesk.service.ICDeskService" />
        <!-- 端口号 -->
        <property name="registryPort" value="8888"></property>
        <!-- <property name="registryHost" value="localhost"></property> -->
    </bean>
    
    
    <!-- spring rmi客户端配置 -->
    <!-- 客户端的接口和服务端借口必须保持一模一样 -->
    <bean id="cdeskProxy" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
        <!-- baseService是调用服务端serviceName的value -->
        <property name="serviceUrl" value="rmi://192.168.0.10:8888/cdesk"></property>
        <!-- service接口 -->
        <property name="serviceInterface" value="com.cdesk.service.ICDeskService"></property>
    </bean>

</beans>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值