尝试运行rmi spring服务器时出现错误。
16 Apr 2019 16:48:16,318 DEBUG org.springframework.remoting.rmi.RmiServiceExporter 394 getRegistry - Looking for RMI registry at port '1099'
16 Apr 2019 16:48:17,588 TRACE org.springframework.remoting.rmi.RmiServiceExporter 404 getRegistry - RMI registry access threw exception
java.rmi.ConnectException: Connection refused to host: 192.168.56.1; nested exception is:
在服务器上,我将其写在xml文件中
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="serviceName" value="Chat"/>
<property name="service" ref="AgencyServerImpl"/>
<property name="serviceInterface" value="agencyServices.IAgencyServer"/>
<property name="servicePort" value="1099"/>
</bean>
在客户端
<bean id="AgencyServerImpl" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://192.168.56.1:1099/Chat"/>
<property name="serviceInterface" value="agencyServices.IAgencyServer"/>
</bean>
在服务器启动时,我使用了
System.setProperty("java.rmi.server.hostname", "192.168.56.1");
ApplicationContext context = new ClassPathXmlApplicationContext("serverBeans.xml");
我所做的一切都是启动服务器,但是我得到了这个错误。谢谢您的帮助!