当前位置: 首页 > 知识库问答 >
问题:

Spring Cloud配置客户端:从错误的服务器获取配置

白才捷
2023-03-14

当我运行Spring Cloud Config Client项目config-client时,我发现了以下错误:

2018-02-09 10:31:09.885  INFO 13933 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2018-02-09 10:31:10.022  WARN 13933 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/config-client/dev/master": 拒绝连接 (Connection refused); nested exception is java.net.ConnectException: 拒绝连接 (Connection refused)
2018-02-09 10:31:10.026  INFO 13933 --- [           main] c.y.c.ConfigClientApplication            : No active profile set, falling back to default profiles: default
2018-02-09 10:31:10.040  INFO 13933 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@33b1c5c5: startup date [Fri Feb 09 10:31:10 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1ffe63b9
2018-02-09 10:31:10.419  INFO 13933 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=65226c2b-524f-3b14-8e17-9fdbc9f72d85
2018-02-09 10:31:10.471  INFO 13933 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$25380e89] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-02-09 10:31:10.688  INFO 13933 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 10001 (http)
2018-02-09 10:31:10.697  INFO 13933 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-02-09 10:31:10.698  INFO 13933 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.27
2018-02-09 10:31:10.767  INFO 13933 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-02-09 10:31:10.768  INFO 13933 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 727 ms
2018-02-09 10:31:10.861  INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-02-09 10:31:10.864  INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-02-09 10:31:10.864  INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-02-09 10:31:10.864  INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-02-09 10:31:10.865  INFO 13933 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-02-09 10:31:10.895  WARN 13933 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configClientApplication': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'content' in value "${content}"
2018-02-09 10:31:10.896  INFO 13933 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-02-09 10:31:10.914  INFO 13933 --- [           main] utoConfigurationReportLoggingInitializer : 

启动ApplicationContext时出错。若要显示自动配置报告,请在启用“debug”的情况下重新运行应用程序。2018-02-09 10:31:10.923错误13933--[main]O.S.Boot.SpringApplication:应用程序启动失败

显然,配置服务器是错误的。但是,Spring Cloud配置服务器运行在localhost:10000/上,项目(config-client)的application.yml在下面。为什么spring.cloud.config.uri不起作用?

application.yml[config-client]

server:
  port: 10001
spring:
  application:
    name: config-client
  cloud:
    config:
      label: master
      profile: dev
      uri: http://localhost:10000

共有1个答案

薛飞星
2023-03-14

如本文所述,在使用Spring Cloud Config Server时,我们应该指定基本的引导设置,例如:Spring.application.namebootstrap.yml(或“bootstrap.properties”)内部的Spring.Cloud.Config.uri

启动时,Spring Cloud使用应用程序的名称对配置服务器进行HTTP调用,并检索回该应用程序的配置。

这就是说,由于我们使用Spring Cloud Config Server外部化了我们的设置,在启动时的引导过程中将覆盖application.yml(或“application.properties”)中定义的任何默认配置。

 类似资料:
  • 我是Spring Cloud的新手,我正在尝试使用存储在github上的属性文件连接服务器和客户端。 我的服务器应用程序。yml文件的配置如下: github回购协议链接在这里,主要属性和替代属性 我的客户端应用程序具有以下设置 Rest控制器是: 所有${变量}van都可以在位于git存储库中的属性文件中找到。 服务器运行正常,但是客户端给了我以下错误 创建名为“rateController”的

  • 配置客户端无法解析配置属性,无法连接到配置服务器。下面是我的服务application.properties文件: pom.xml中的依赖关系:

  • 我有一个web应用程序,我想使用Spring Boot的服务器配置。这两个应用程序都位于本地主机上。我从头开始创建了前两个应用程序,它们一起工作,但当我使用具有许多依赖项(不仅仅是云配置和web依赖项)的客户端时,它就不再工作了。我怎么知道?我在服务器的属性文件中有一个变量,我试图在我的客户机中用@Value(“${atena}”)来使用它,错误出现在java中。lang.IllegalArgum

  • 错误: > 连客户端都没有启动 http://localhost:8080/ 将spring.config.import=configServer:属性添加到您的配置中。如果不需要配置,则添加spring.config.import=optional:configserver:。要禁用此检查,请设置spring.cloud.config.enabled=false或spring.cloud.con

  • 我正在得到 [2012年4月24日星期二 12:12:55][错误][客户端 127.0.0.1] 客户端被服务器配置拒绝:/labs/Projects/Nebula/bin/ 我的目录结构如下(我使用的是Symfony 2,其他web框架的结构应该类似) 我有这样的vhosts设置: 我想知道出了什么问题,我该如何解决它?

  • 我有一个短期任务,客户端到spring云配置。(依赖于spring cloud starter配置或spring cloud配置客户端)。 正如我提到的,这是一个短暂的任务,它启动、从服务器加载配置、进行一些处理并关闭。 问题是spring-cloud d-config-Client启动Web服务器(tomcat),这是冗余的-我不想在我的客户端应用程序/任务上启动Web服务器。 我知道这个Web