在Springboot 3中占位符无法识别该类

问题描述 投票:0回答:1
below is the yml config
feign:
   baseurl
@FeignClent(value ="abc.xyz.app", url = "${feign.baseurl}")) 
public interface ExamplseService {
}

启动服务器时,我尝试从 application.yml 调用 feign 客户端 url,但它没有帮助它抛出以下错误

引起:java.lang.IllegalArgumentException:无法解析值“http://${feign.baseurl}”中的占位符“feign.baseurl” 在 org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180) 在

java-17 spring-boot-3
1个回答
0
投票

首先尝试通过直接注入值来测试您的网址:

@FeignClient(value = "abc.xyz.app", url = "${feign.baseurl:http://default.baseurl.com}")

如果它有效,那么您的 application.properties 或 application.yml 文件可能有问题,在这种情况下,请将您的 url 添加到属性文件中,并确保在运行时首先检测到它。

application.yml:

feign:
  baseurl: http://your-base-url.com

或者如果您有 application.properties :

feign.baseurl=http://your-base-url.com

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