淺談升級(jí)Spring Cloud到Finchley后的一點(diǎn)坑
最近為了使用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ī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
關(guān)于Java中的try-with-resources語(yǔ)句
這篇文章主要介紹了關(guān)于Java中的try-with-resources語(yǔ)句,try-with-resources是Java中的環(huán)繞語(yǔ)句之一,旨在減輕開(kāi)發(fā)人員釋放try塊中使用的資源的義務(wù),需要的朋友可以參考下2023-05-05
java多線程CyclicBarrier的使用案例,讓線程起步走
這篇文章主要介紹了java多線程CyclicBarrier的使用案例,讓線程起步走!具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-02-02
Spring AOP中定義切點(diǎn)的實(shí)現(xiàn)方法示例
這篇文章主要介紹了Spring AOP中定義切點(diǎn)的實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了spring面向切面AOP定義切點(diǎn)的具體步驟、實(shí)現(xiàn)方法與相關(guān)操作技巧,需要的朋友可以參考下2020-01-01
在SpringBoot中集成H2數(shù)據(jù)庫(kù)的完整指南
Spring Boot是一個(gè)簡(jiǎn)化企業(yè)級(jí)Java應(yīng)用程序開(kāi)發(fā)的強(qiáng)大框架,H2數(shù)據(jù)庫(kù)是一個(gè)輕量級(jí)的、開(kāi)源的SQL數(shù)據(jù)庫(kù),非常適合用于開(kāi)發(fā)和測(cè)試,本文將指導(dǎo)您如何在Spring Boot應(yīng)用程序中集成H2數(shù)據(jù)庫(kù),并探索一些高級(jí)配置選項(xiàng),需要的朋友可以參考下2024-10-10
教你用Java實(shí)現(xiàn)RSA非對(duì)稱加密算法
今天帶各位小伙伴學(xué)習(xí)怎么用Java實(shí)現(xiàn)RSA非對(duì)稱加密算法,文中有非常詳細(xì)的解釋及代碼示例,對(duì)正在學(xué)java算法的小伙伴們很有幫助,需要的朋友可以參考下2021-05-05
SpringBoot項(xiàng)目沒(méi)有把依賴的jar包一起打包的問(wèn)題解決
這篇文章主要介紹了SpringBoot項(xiàng)目沒(méi)有把依賴的jar包一起打包的問(wèn)題解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-09-09

