浅谈升级Spring Cloud到Finchley后的一点坑

网友投稿 268 2023-01-20


浅谈升级Spring Cloud到Finchley后的一点坑

最近为了使用Kotlin以及Webflux进行后台应用开发,把Spring Cloud版本升级到了Finchley。

这种http://大版本的提升,坑自然是少不了的,我最近会把遇到问题都总结在这里避免大家花太多时间在排坑上:

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:

    Prohttp://perty: eureka.instance.instance-id

    Value: ${spring.cloud.client.ipAddress}:${spring.application.name}:${spring.application.instance_id:${server.port}}

    Origin: "eureka.instanlSPiVce.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这个参数已经不能被识别了

我们来看看源码:

# org.springframework.cloud.client.HostInfoEnvironmentPostProcessor

@Override

public void postProcessEnvironment(ConfigurableEnvironment environment,

SpringApplication application) {

InetUtils.HostInfo hostInfo = getFirstNonLoopbackHostInfo(environment);

LinkedHashMap 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);

}

发现原来的ipAddress已经改为ip-address,那么我们在配置中心做相应的改正即可。

注:改为ip-address不会对之前的老版本的项目产生影响,会自动解析并正确赋值


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:集团研发管理平台(集团研发管理平台官网)
下一篇:如何实现接口的关联功能(如何实现接口的关联功能设置)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~