java如何获取当前机器ip和容器port

获取当前机器ip:

private static String getIpAddress() throws UnknownHostException {   

        InetAddress address = InetAddress.getLocalHost();   

  

        return address.getHostAddress();   

}

 

获取容器port:

String port = String.valueOf(request.getLocalPort());

你可能感兴趣的:(java)