Spring Cloud Config客户端无法在Grails 3 app中刷新/刷新

时间:2018-01-25 21:26:25

标签: grails spring-cloud-config

我已成功启动Config Server(支持git repo),为grails 3.3.0groovy中的配置客户端REST服务提供动态配置属性。

客户端在启动时加载其配置完美。当通过git repo进行更改时,配置服务器会看到它们。

当我点击客户端上的/refresh时,它会在我点击执行器端点/env时看到更改。有更新的财产。没有错误并且完美无缺。

问题:

/refresh不会更改正在运行的应用中的简单属性(ad.username)。它继续使用旧的。 这是我Grails service课程中的内容:

@RefreshScope
@Transactional
public class MyService {

    @Value('${ad.username:defaultLdapUsername}')
    String username

    @Value('${ad.password:defaultLdapPassword}')
    String password

    @Value('${ad.hostname:defaultLdapHostname}')
    String hostname

...
}

@RefreshScope不起作用。我尝试使用MyConfig.groovy单独@ConfigurationProperties(prefix = "ad"),但没有运气。

我是@Autowired服务类中的Grails bean吗?

我不确定问题出在哪里,可以使用一些帮助或示例项目/代码。

Grails 3 Spring Boot,但我想知道这里是否存在一些差异。

感谢。

1 个答案:

答案 0 :(得分:0)

我会在调试的下一步添加其中一个:

@EventListener
public void refresh (RefreshScopeRefreshedEvent e ) {
logger.info(“refreshed”); 
}
相关问题