config-client 控制台启动异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in value "${foo}"
config-server 控制台:
2019-03-14 03:21:16.577 INFO 16486 --- [nio-8888-exec-7] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
config-client的配置文件
spring:
application:
name: config-client
cloud:
config:
label: master
profile: dev
uri: http://localhost:8888/
**#name: server-config**
server:
port:8881
config-server服务启动后,可以正常访问git上面的配置文件,但是启动config-client不能通过配置spring.config.uri: http://localhost:8888/ 从git上面获取配置文件。从网上查询了很多资料,说是dns解析慢,于是查找超时配置,在InetUtilsProperties类中配置的
@Value("${spring.util.timeout.sec:${SPRING_UTIL_TIMEOUT_SEC:1}}")
private int timeoutSeconds = 1;
于是在配置文件中配置,也没有起作用。
inetutils:
timeout-seconds: 5
最后在config-client配置中添加 name: server-config,server-config是 config服务的id。直接指向要访问的服务,自此config-client不再异常,config-server控制台显示正常:
Adding property source: file:/var/folders/n1/ck6zl6zx04x_40x6ldz2nlk80000gn/T/config-repo-3607293225866814317/respo/server-config-dev.properties
搞得懵懵懂懂的,有大神懂得,请不吝赐教
网友评论