Skip to content

@ApolloConfigChangeListener 无效 #51

@Sam0913

Description

@Sam0913

`
@slf4j
@component
public class ApolloConfig implements ApplicationContextAware {

private ApplicationContext applicationContext;

@ApolloConfigChangeListener
public void onChange(ConfigChangeEvent changeEvent){
    log.info("apollo conf update starts!");
    // 更新configrationProperties
    applicationContext.publishEvent(new EnvironmentChangeEvent(changeEvent.changedKeys()));
    log.info("apollo conf update success!");
}

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext.getParent();
}

}
`

这边能取到最新配置,但是使用@ConfigurationProperties(prefix = "spring.datasource")的配置还是久的值

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions