使用spring cloud的config配置中心時在使用這個配置的文件中配置了請求路徑但是沒生效如:
#application.yml
spring: cloud: config: discovery: enabled: true service-id: config-server name: user-service profile: dev uri: http://localhost:6001 eureka: client: service-url: defaultZone: http://eureka1:2001/eureka, http://eureka2:2002/eureka
2020-01-07 10:21:37.305 INFO 4816 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888 2020-01-07 10:21:38.393 INFO 4816 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available 2020-01-07 10:21:38.394 WARN 4816 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/user-service/dev": Connection refused:
connect; nested exception is java.net.ConnectException: Connection refused: connect 2020-01-07 10:21:38.395 INFO 4816 --- [ main] cn.tedu.sp03.Sp03UserserviceApplication : No active profile set, falling back to default profiles: default 2020-01-07 10:21:38.975 WARN 4816 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
我在這兒申明了路徑是http://localhost:6001 但是還是訪問的http://localhost:8888,也就是說明配置未生效,這時只需要將配置文件的名字修改為bootstrap.yml即可,這個文件的加載優先級高於application.yml;