使用这段代码获取IP 就会报错
InetAddress.getLocalHost().getHostName();
错误堆栈信息:
00:50:56.166 [main] ERROR RocketmqCommon - Failed to obtain the host name
java.net.UnknownHostException: HEIHEI: HEIHEI
at java.net.InetAddress.getLocalHost(InetAddress.java:1505) ~[na:1.8.0_131]
at org.apache.rocketmq.common.BrokerConfig.localHostName(BrokerConfig.java:200) [classes/:na]
at org.apache.rocketmq.common.BrokerConfig.<init>(BrokerConfig.java:40) [classes/:na]
at org.apache.rocketmq.broker.BrokerStartup.createBrokerController(BrokerStartup.java:124) [classes/:na]
at org.apache.rocketmq.broker.BrokerStartup.main(BrokerStartup.java:69) [classes/:na]
Caused by: java.net.UnknownHostException: HEIHEI
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_131]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_131]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_131]
at java.net.InetAddress.getLocalHost(InetAddress.java:1500) ~[na:1.8.0_131]
... 4 common frames omitted
Process finished with exit code -3
电脑: win 10 求大佬帮忙看看,跪谢。