溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

升級(jí)Spring Cloud到Finchley后會(huì)遇到什么坑

發(fā)布時(shí)間:2021-09-09 14:10:41 來(lái)源:億速云 閱讀:91 作者:小新 欄目:編程語(yǔ)言

這篇文章主要為大家展示了“升級(jí)Spring Cloud到Finchley后會(huì)遇到什么坑”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“升級(jí)Spring Cloud到Finchley后會(huì)遇到什么坑”這篇文章吧。

最近為了使用Kotlin以及Webflux進(jìn)行后臺(tái)應(yīng)用開(kāi)發(fā),把Spring Cloud版本升級(jí)到了Finchley。

這種大版本的提升,坑自然是少不了的,我最近會(huì)把遇到問(wèn)題都總結(jié)在這里避免大家花太多時(shí)間在排坑上:

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這個(gè)參數(shù)已經(jīng)不能被識(shí)別了

我們來(lái)看看源碼:

# org.springframework.cloud.client.HostInfoEnvironmentPostProcessor

@Override
  public void postProcessEnvironment(ConfigurableEnvironment environment,
      SpringApplication application) {
    InetUtils.HostInfo hostInfo = getFirstNonLoopbackHostInfo(environment);
    LinkedHashMap<String, Object> map = 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)原來(lái)的ipAddress已經(jīng)改為ip-address,那么我們?cè)谂渲弥行淖鱿鄳?yīng)的改正即可。

注:改為ip-address不會(huì)對(duì)之前的老版本的項(xiàng)目產(chǎn)生影響,會(huì)自動(dòng)解析并正確賦值

以上是“升級(jí)Spring Cloud到Finchley后會(huì)遇到什么坑”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI