Spring Boot : Error: Exception thrown by the agent

2019-12-16 17:56发布

问题:

I have installed Spring Tool Suite on Eclipse (STS 3.9.2), I created a Demo application, but when I run it as "Spring Boot App" I get the following error :

Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: linux-se15: linux-se15: Name or service not known

Running this command gives the following result :

  hostname --fqdn
  hostname: Name or service not known

/etc/hosts has the following :

127.0.0.1   localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts

回答1:

The cause of the problem may be hosts and hostname files. hosts file should contain something like this:

127.0.0.1       localhost
127.0.1.1       yourhostname

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

hostname file should contain yourhostname.
You can edit them by using sudo nano /etc/hosts and sudo nano /etc/hostname.