当前位置:主页 > java教程 > 浅谈升级Spring Cloud到Finchley后的一点坑

Spring Cloud到Finchley升级详解

发布:2020-03-30 09:32:58 113


给大家整理了Spring Cloud相关的编程文章,网友訾明旭根据主题投稿了本篇教程内容,涉及到Spring、Cloud、Finchley、浅谈升级Spring Cloud到Finchley后的一点坑相关内容,已被361网友关注,如果对知识点想更进一步了解可以在下方电子资料中获取。

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

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

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

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这个参数已经不能被识别了

我们来看看源码:

# 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);
  }

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

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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持码农之家。


参考资料

相关文章

  • Spring @ComponentScan注解扫描组件原理

    发布:2023-03-04

    这篇文章主要介绍了Spring @ComponentScan自动扫描组件使用,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下


  • SpringMVC Interceptor拦截器使用教程

    发布:2023-03-08

    SpringMVC中拦截器(Interceptor)用于对URL请求进行前置/后置过滤,Interceptor与Filter用途相似,但实现方式不同。Interceptor底层就是基于Spring AOP 面向切面编程实现


  • Spring Boot报错:No session repository could be auto-configured, check your configuration如何解决

    发布:2019-10-19

    这篇文章主要给大家介绍了关于Spring Boot报错:No session repository could be auto-configured, check your configuration的解决方法,文中给出了详细的解决方法,对遇到这个问题的朋友们具有一定参考价值,需


  • Spring Boot Shiro auto-configure工作流程详解

    发布:2023-04-06

    这篇文章主要为大家介绍了Spring Boot Shiro auto-configure工作流程详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪


  • spring Cloud微服务阿里开源TTL身份信息的线程间复用

    发布:2023-03-02

    这篇文章主要为大家介绍了spring Cloud微服务中使用阿里开源TTL身份信息的线程间复用,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪


  • Spring责任链模式使用实例讲解

    发布:2023-03-05

    责任链是行为型设计模式的一种,通过前一个处理者记录下一个处理者的方式形成一条处理链。客户端在调用时只需要将请求传递到责任上即可,无需关注链路中的具体的传递过程。而链路中内部的处理,是按照前一个处理者记录的下一个处理者依次执行


  • Spring使用AOP完成统一结果封装实例demo

    发布:2023-04-14

    这篇文章主要介绍了Spring使用AOP完成统一结果封装,本文通过实现demo给大家详细讲解,代码简单易懂,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下


  • Spring Retry实现原理及实例

    发布:2019-06-07

    这篇文章主要介绍了详解Spring Retry实现原理,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧


网友讨论