RefreshScope declared Beans are not refreshed
Type: Bug
Component: Parameter Store
Describe the bug
Hello Team,
Thank you for your awesome work, I have stumbled upon an issue, I have declared a bean as @RefreshScope, this bean depends on another bean of @ConfigurationProperties, the @ConfigurationProperties does get refreshed however the @RefreshScope bean does not get refreshed.
Sample
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "prop")
public class PropConfigurationProperties {
private String baseUrl;
}
@Slf4j
@Configuration
@RequiredArgsConstructor
public class WebConfig {
@Bean
@RefreshScope
PropClient propClient(PropConfigurationProperties properties, WebClient.Builder builder) {
System.out.println("Base URL: " + properties.getBaseUrl());
WebClient build = builder.baseUrl(properties.getBaseUrl()).build();
return HttpServiceProxyFactory.builder()
.exchangeAdapter(WebClientAdapter.create(build))
.build()
.createClient(PropClient.class);
}
@EventListener
public void handleContextRefresh(RefreshScopeRefreshedEvent event) {
System.out.println(event);
System.out.println("🔄 RefreshScopeRefreshedEvent triggered at: " + System.currentTimeMillis());
}
@EventListener
public void handleEnvironmentChange(EnvironmentChangeEvent event) {
System.out.println("🔄 EnvironmentChangeEvent triggered: " + event.getKeys());
}
}
Both the @EventListener are triggered and I do see the output, however I do not see the output of System.out.println("Base URL: " + properties.getBaseUrl()); when the @EventListener are triggered. Please do let me know what am I doing wrong?
Hey @ct-dev-team ,
could you please provide a sample repository so we can reproduce the issue?
Also, do you have actuator dependency in your poject?