java.lang.IllegalStateException:无法找到PropertySource并设置了fail fast属性,导致Microservices失败

时间:2018-08-19 13:27:27

标签: spring-boot microservices

我正在通过链接https://github.com/sqshq/PiggyMetrics关注微服务。我能够简单地成功启动“ config”服务,但是当我尝试启动“ registry”服务时,出现以下错误。

任何人都可以在问题上提供指导吗?我看不到任何有关设置或运行微服务的适当步骤。

2018-08-19 18:55:15.424  INFO 12700 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://config:8888
2018-08-19 18:55:17.805  INFO 12700 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://config:8888. Will be trying the next url if available
2018-08-19 18:55:17.826 ERROR 12700 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Could not locate PropertySource and the fail fast property is set, failing
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:136) ~[spring-cloud-config-client-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:94) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:633) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:373) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
    at com.piggymetrics.registry.RegistryApplication.main(RegistryApplication.java:12) [classes/:na]
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://config:8888/registry/default": config; nested exception is java.net.UnknownHostException: config
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:732) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:680) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:600) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.getRemoteEnvironment(ConfigServicePropertySourceLocator.java:218) ~[spring-cloud-config-client-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.locate(ConfigServicePropertySourceLocator.java:96) ~[spring-cloud-config-client-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    ... 7 common frames omitted
Caused by: java.net.UnknownHostException: config
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.SocksSocketImpl.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_151]
    at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_151]
    at sun.net.NetworkClient.doConnect(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.<init>(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) ~[na:1.8.0_151]
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) ~[na:1.8.0_151]
    at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:723) ~[spring-web-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    ... 11 common frames omitted

enter image description here

1 个答案:

答案 0 :(得分:0)

您已提供“ config”作为配置服务的主机名。用正确的主机名替换它。

spring:
  application:
    name: <name>
  cloud:
    config:
      uri: http://host:port
      fail-fast: true
      password: <password>
      username: <user>

由于该应用程序无法解析“ config”,因此它为您提供UnknownHost异常。