从 application.yaml 读取 FeignClient url 不起作用

问题描述 投票:0回答:1

我正在尝试从 application.yaml 读取 Feign 客户端 url,我没有使用功能区。 Ribbon之前工作过,现在我迁移到Spring Boot 3.1.4和Spring Cloud 2022.0.3

@FeignClient(name = "new-common-service", url = "${spring.cloud.openfeign.client.config.new-common-service.url}")
public interface NewCommonServiceClient {
@GetMapping(value = "/test")
ResponseEntity<?> testRequest();

}

在应用程序yaml中

cloud:
    openfeign:
      client:
        config:
          new-common-service:
          url: localhost:9090/serve

显示错误

java.lang.IllegalArgumentException:http://${cloud.openfeign.client.config.new-common-service.url} 格式错误 原因:java.net.MalformedURLException:在主机中发现非法字符:'{'

如何解决这个问题

我希望从应用程序 yaml 文件中读取 FeignClient url 值

spring-boot spring-cloud spring-cloud-feign openfeign property-placeholder
1个回答
0
投票

我为这个问题苦苦挣扎了一个多星期。我更新了我的 IntelliJ,现在它又可以工作了。

© www.soinside.com 2019 - 2024. All rights reserved.