最近为了使用Kotlin以及Webflux进行后台应用开发,把Spring Cloud版本升级到了Finchley。
这种大版本的提升,坑自然是少不了的,我最近会把遇到问题都总结在这里避免大家花太多时间在排坑上:
Failed to bind properties under ‘eureka.instance.instance-id\' to java.lang.String:
De ion:
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.spring work.cloud.client.HostInfoEnvironmentPostProcessor
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
InetUtils.HostInfo hostInfo = getFirstNonLoopbackHostInfo(environment);
edHashMap<String, > map = new edHashMap<>();
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不会对之前的老版本的项目产生影响,会自动解析并正确赋值
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
继续阅读与本文标签相同的文章
-
word公式编辑器的使用方法
2026-05-19栏目: 教程
-
库克有多牛?上任8年,让苹果营收涨4倍,市值涨4倍,全球第一
2026-05-19栏目: 教程
-
道通奔驰在线编程全新版本V17.00正式发布
2026-05-19栏目: 教程
-
《吊打面试官》系列-Redis基础
2026-05-19栏目: 教程
-
税控盘操作流程大全!
2026-05-19栏目: 教程
