美文网首页
InetAddress.getLocalHost()报错 Ca

InetAddress.getLocalHost()报错 Ca

作者: lvb001 | 来源:发表于2018-10-18 13:26 被阅读0次

    报错详情:Caused by: java.net.UnknownHostException: ecs-4482-0002.novalocal: Name or service not known

    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)

    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)

    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295)

    at java.net.InetAddress.getLocalHost(InetAddress.java:1471)

    ... 38 more

    问题原因:

    解决方法:

    首先在Linux命令行中查看hostname

    [root@yun_app bin]# hostname

    yun_app

    在/etc/hosts中添加一行

    127.0.0.1  yun_app

    再用下列命令查看,出来结果即正确

    [root@yun_app bin]# hostname -i

    127.0.0.1

    相关文章

      网友评论

          本文标题:InetAddress.getLocalHost()报错 Ca

          本文链接:https://www.haomeiwen.com/subject/rdgjzftx.html