我有一个属性类,如下所示:
@Component
@ConfigurationProperties(prefix = "gateway")
public class GatewayConfigurationProperties {
private Map<String, String> publisherMessageProperties;
public Map<String, String> getPublisherMessageProperties() {
return publisherMessageProperties;
}
public void setPublisherMessageProperties(Map<String, String> publisherMessageProperties) {
this.publisherMessageProperties = publisherMessageProperties;
}
}
我正在用构造函数注入将上述组件连接到另一个@component类中。
@Component
public class EventListener {
private GatewayConfigurationProperties gatewayProperties;
public EventListener(GatewayConfigurationProperties gatewayProperties) {
this.gatewayProperties = gatewayProperties;
}
public void onMessage(Message message) {
System.out.println(gatewayProperties.getPublisherMessageProperties());
}
应用程序是一个配置客户机,其属性也存储在gitlab中。gatewayconfigurationproperties中属性的值在gitlab中更改,我正在调用actuator的/actuator/refresh端点。我可以在日志中看到端点调用,但是gitlab中属性的更改没有反映出来。在@component类或properties类上还有什么要做的吗。当我阅读文档时,我可以看到用@configurationproperties注解的类将用actuator刷新,但不知怎么的,这并没有发生在我身上
暂无答案!
目前还没有任何答案,快来回答吧!