【Spring Cloud】解決Failed to bind properties under eureka.client.service-url to

一、錯誤描述

Description:

Failed to bind properties under 'eureka.client.service-url' to java.util.Map<java.lang.String, java.lang.String>:

    Reason: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]

Action:

Update your application's configuration

二、問題分析

遵循原則:哪報錯找哪
報錯信息

No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]

不能將service-url從String類型轉換爲Map類型的

三、解決辦法

打開application.yml配置文件,在defaultZone:後加空格
在這裏插入圖片描述
如果不加空格

  • defaultZone: http://127.0.0.1:${server.port}/eureka/
  • 整體是一個String類型

加上空格後

  • defaultZone 爲key
  • http://127.0.0.1:${server.port}/eureka/爲value
  • 整體是一個Map類型
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章