Describe the bug In FeignClientsRegistrar resolve, it use beanFactory.resolveEmbeddedValue to explain the value, but there is no EmbeddedValueResolver because PropertySourcesPlaceholderConfigurer is not init before FeignClientsRegistrar .Is it a bug or any solution to fix it.

Sample

@FeignClient(name = "${sid}", path = "test", contextId = "${sid}")

and sid: xxx in application.yml

Comment From: haitaoss

Describe the bug In FeignClientsRegistrar resolve, it use beanFactory.resolveEmbeddedValue to explain the value, but there is no EmbeddedValueResolver because PropertySourcesPlaceholderConfigurer is not init before FeignClientsRegistrar.Is it a bug or any solution to fix it.

Sample @FeignClient(name = "${sid}", path = "test", contextId = "${sid}")

and sid: xxx in application.yml

I think the code for the main branch has already solved this problem. You can use this method to easily handle it

@Slf4j
public class MyApplicationContextInitializer implements ApplicationContextInitializer {
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
        if (!beanFactory.hasEmbeddedValueResolver()) {
            beanFactory.addEmbeddedValueResolver(strVal -> applicationContext.getEnvironment()
                    .resolvePlaceholders(strVal));
        }
    }
}

META-INF/spring.factories

org.springframework.context.ApplicationContextInitializer=\
  cn.haitaoss.config.MyApplicationContextInitializer

Comment From: OlgaMaciaszek

Hello @qq583137502, this should work properly on the latest supported versions (4.0.4, 4.1.0). If you still face an issue on any of these versions, please provide a minimal, complete, verifiable example that reproduces the issue.

Comment From: spring-cloud-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.