Java获取当前服务器ip
Java获取当前服务器ip
参考 https://www.cnblogs.com/-llf/p/11769799.html
import java.net.InetAddress; import java.net.UnknownHostException; public class ServerIpUtil { public static String getLocalServerIp() { try { InetAddress inetAddress = InetAddress.getLocalHost(); String localServerIp = inetAddress.getHostAddress(); return localServerIp; } catch (UnknownHostException e) { LoggerUtil.error(e.getMessage(), e); return "500"; } } }