首页 新闻 搜索 专区 学院

Spring Cloud Config Client默认连接config server:http://localhost:8888,如何改变

0
[待解决问题]

1. 首先我启动了Spring Cloud Config Server,并且通过他成功访问了git仓库的文件

配置文件如下:

server:
  port: 10000
spring:
  application:
    name: config-server
  cloud:
    config:
      server:
        git:
          uri: https://github.com/souyunku/spring-cloud-config.git
      label: master

2. 然后我新建了Spring Cloud Config Client项目config-client,配置文件如下:

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

我指定连接config server的uri为 uri: http://localhost:10000,可是当我启动这个项目的时候报错:

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 : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-02-09 10:31:10.923 ERROR 13933 --- [           main] o.s.boot.SpringApplication               : Application startup failed

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}"

错误很明显,报错显示这个client项目连接的server为默认的8888端口,并不是我设定的10000端口,这是为什么呢?求各位大神指点

闫文雄的主页 闫文雄 | 菜鸟二级 | 园豆:226
提问于:2018-02-09 10:32
< >
分享
所有回答(1)
-2

将配置文件改名为 :bootstrap ,默认加载的配置是按这个bootstrap文件名来的,看下ConfigServerBootstrapConfiguration这个源码

刺客决心 | 园豆:206 (菜鸟二级) | 2018-02-27 13:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册