InetAddress.getLocalHost().getHostAddress() 通过这个命令来获取本机的IP不一定正确。 我在开了虚拟机后获得的ip竟然是虚拟机的ip,不知道这个函数内部具体是怎么实现的。