這篇文章主要為大家展示了“升級Spring Cloud到Finchley后會遇到什么坑”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“升級Spring Cloud到Finchley后會遇到什么坑”這篇文章吧。
最近為了使用Kotlin以及Webflux進行后臺應(yīng)用開發(fā),把Spring Cloud版本升級到了Finchley。
這種大版本的提升,坑自然是少不了的,我最近會把遇到問題都總結(jié)在這里避免大家花太多時間在排坑上:
Failed to bind properties under ‘eureka.instance.instance-id' to java.lang.String:
Description:
Failed to bind properties under 'eureka.instance.instance-id' to java.lang.String:
Property: eureka.instance.instance-id
Value: ${spring.cloud.client.ipAddress}:${spring.application.name}:${spring.application.instance_id:${server.port}}
Origin: "eureka.instance.instance-id" from property source "bootstrapProperties"
Reason: Could not resolve placeholder 'spring.cloud.client.ipAddress' in value "${spring.cloud.client.ipAddress}:${spring.application.name}:${spring.application.instance_id:${server.port}}"
spring.cloud.client.ipAddress
這個參數(shù)已經(jīng)不能被識別了
我們來看看源碼:
# org.springframework.cloud.client.HostInfoEnvironmentPostProcessor @Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { InetUtils.HostInfo hostInfo = getFirstNonLoopbackHostInfo(environment); LinkedHashMapmap = new LinkedHashMap<>(); map.put("spring.cloud.client.hostname", hostInfo.getHostname()); map.put("spring.cloud.client.ip-address", hostInfo.getIpAddress()); MapPropertySource propertySource = new MapPropertySource( "springCloudClientHostInfo", map); environment.getPropertySources().addLast(propertySource); }
發(fā)現(xiàn)原來的ipAddress已經(jīng)改為ip-address,那么我們在配置中心做相應(yīng)的改正即可。
注:改為ip-address不會對之前的老版本的項目產(chǎn)生影響,會自動解析并正確賦值
以上是“升級Spring Cloud到Finchley后會遇到什么坑”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!