spring - 在 null 中定义的名称 [...] 的无效 bean 定义:无法使用 JHipster 和 @AuthorizedFeignClient 解析占位符
问题描述
我正在使用 JHipster FeignClients 进行服务间通信。我想根据我的环境更改我的 feignClient 的主机名。如果我尝试构建我的应用程序,我会收到以下错误:
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'com.abcd.uaa.clients.ProductServiceClient' defined in null: Could not resolve placeholder 'application.productservice' in value "http://${application.productservice}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'application.productservice' in value "http://${application.productservice}"
如果我在开发环境中运行我的构建,它似乎可以工作,但我的产品环境失败。我的应用程序配置如下:
UaaApp.class
@SpringBootApplication
@EnableFeignClients
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class})
@EnableDiscoveryClient
public class UaaApp implements InitializingBean {...}
应用程序属性.java
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = false)
public class ApplicationProperties {
private String productservice = "";
public String getProductservice() {
return productservice;
}
public void setProductservice(String productservice) {
this.productservice = productservice;
}
}
ProductServiceClient.java
@AuthorizedFeignClient(name = "productservice", decode404 = true, url = "${application.productservice}")
public interface ProductServiceClient {...}
应用程序-dev.yml
application:
productservice: http://localhost:8082
应用程序-prod.yml
application:
productservice: http://hostname:8082
我错过了什么吗?
解决方案
推荐阅读
- mysql - 在没有来自 MySQL 的键的情况下循环对象字典
- elasticsearch - 使用传输客户端的安全弹性连接
- c++ - 为什么我不能为 std::forward 使用像 std::move 这样的转发引用的单一版本?
- angular - 嗨,我在 angular 中使用 find 函数时出错“无法读取未定义的属性查找
- python - 从列表中创建一个矩阵
- java - Xamrain 应用程序权限访问被拒绝问题?
- azure - 通过 AppId/BotId 注册 Azure Bot Service bot 时,Teams 如何知道它的端点?
- javascript - Mongoose:在数组中查找和更新对象
- bash - 将指定行数打印到标准输出后切断程序
- vhdl - 使用时钟使能输出显示