首页 > 解决方案 > 在 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

我错过了什么吗?

标签: springspring-bootdockerjhipsterfeign

解决方案


推荐阅读