修复启动监听时,多网卡导致服务注册失效的bug
This commit is contained in:
parent
24223d7545
commit
6c99b59002
|
@ -34,4 +34,7 @@ mail.freemarker.template=/email_template/
|
|||
#第三方平台推送开关 true打开 false关闭
|
||||
task.push.switch=false
|
||||
#第三方平台推送URL
|
||||
task.push.url=localhost
|
||||
task.push.url=localhost
|
||||
#==================================RMI接口指定本地IP============================================
|
||||
#当客户端存在多个网卡(如:虚拟机的网卡),那么客户端就存在多个IP,此时必须指定一个实际IP地址注册RMI服务,如果只有一个网卡,可默认localhost
|
||||
client.localhost.ip=localhost
|
|
@ -2,6 +2,7 @@ package rmi.remotingservice;
|
|||
|
||||
import java.rmi.Naming;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
import java.util.Properties;
|
||||
|
||||
import rmi.service.RunService;
|
||||
import rmi.serviceimpl.RunServiceImpl;
|
||||
|
@ -22,12 +23,17 @@ public class Program{
|
|||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
Properties properties= luckyclient.publicclass.SysConfig.getConfiguration();
|
||||
String localhostip=properties.getProperty("client.localhost.ip");
|
||||
if(!"localhost".toLowerCase().equals(localhostip)){
|
||||
System.setProperty("java.rmi.server.hostname", localhostip);
|
||||
}
|
||||
RunService runService=new RunServiceImpl();
|
||||
//×¢²áͨѶ¶Ë¿Ú
|
||||
LocateRegistry.createRegistry(6633);
|
||||
//×¢²áͨѶ·¾¶
|
||||
Naming.rebind("rmi://localhost:6633/RunService", runService);
|
||||
System.out.println("启动客户端监听...端口:6633");
|
||||
Naming.rebind("rmi://"+localhostip+":6633/RunService", runService);
|
||||
System.out.println("启动客户端监听...IP:"+localhostip+" 端口:6633");
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue