com.github.dc.invoke.util.IpAddressUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dc-invoke Show documentation
Show all versions of dc-invoke Show documentation
dc-invoke project for Spring Boot
package com.github.dc.invoke.util;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import java.net.InetAddress;
/**
*
*
*
* @author wangpeiyuan
* @date 2022/6/8 10:35
*/
@UtilityClass
@Slf4j
public class IpAddressUtil {
public static InetAddress getLocalHost() {
try {
return InetAddress.getLocalHost();
} catch (Exception e) {
log.warn("获取当前服务器ip异常");
}
return null;
}
public static String getIp() {
try {
return getLocalHost().getHostAddress();
} catch (Exception e) {
log.warn("获取当前服务器ip异常");
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy