centOS 之 java.net.UnknownHostException: centos: centos: 未知的名称或服务


  • 应用场景:启动javaWeb项目时,报错后终止。提示如下:

    Initializing EhCache CacheManager
    2019-10-21 22:36:20.486 ERROR 9783 --- [ main] net.sf.ehcache.Cache :
    Unable to set localhost. This prevents creation of a GUID. Cause was: centos: centos: 未知的名称或服务

      java.net.UnknownHostException: centos: centos: 未知的名称或服务
       at java.net.InetAddress.getLocalHost(InetAddress.java:1506) ~[na:1.8.0_231]
       at net.sf.ehcache.Cache.<clinit>(Cache.java:214) ~[ehcache-core-2.6.11.jar!/:na]
       at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:296) [ehcache-core-2.6.11.jar!/:na]
       at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:219) [ehcache-core-2.6.11.jar!/:na]
       at net.sf.ehcache.CacheManager.configure(CacheManager.java:722) [ehcache-core-2.6.11.jar!/:na]
    
  • 产生原因: 当前用户未同 127.0.0.1建立映射关系

  • 解决办法: 编辑hosts文件,将报错名称添加到127.0.0.1的映射中

      127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4  centos //此处添加centos
      ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM