在成功设置了云配置服务器并确认所有功能都按预期运行后,我遇到了这个问题,但我不确定它是否受支持或最佳路径。
我们遵循数据库每服务模式,因此我进行了一个实验,我提交了一个包含每个服务的数据库连接详细信息的dev和staging文件,以便如果需要更改服务器地址和凭证,我们只需要在配置回购。
我已经正确设置了这一点,并确认这些更改确实从配置服务器传播到客户端。
只有在做完所有这些之后,我才注意到即使服务获得了更新的数据库详细信息,它也不会切换其连接。
这可能吗? 我能做到这一点的唯一方法就是如果我重新启动了服务,而且这种做法已经失去了实现所有这一切的目的。 我尝试了连接超时,但它没有帮助。 该服务仍然连接到以前的连接。
After successfully setting up a cloud config server and confirming that all works as expected I ran into this issue but I'm not sure if it's supported or the best way to go.
We follow the database-per-service pattern so as an experiment I committed a dev and staging file containing the db connection details of each service so that if we needed to make changes to the server address and credentials we only needed to do it in the config repo.
I have set this up correctly and I confirm that the changes are indeed being propagated from the config server to the clients.
It was only after doing all of this did I notice that even though the services got the updated database details it DID NOT switch its connection.
Is this possible? The only way I could do this was if I restarted the service and that kinda defeats the purpose of having all of this in place. I tried toying with the connection timeouts but it didn't help. The service was still connected to the previous connection.
最满意答案
所以它看起来简单的添加了@RefreshScope到我的控制器中。 感谢Spring的David Syer的洞察力。
So it appears a simple addition of the @RefreshScope to my controller did the trick. Thanks to Spring's David Syer for the insight.
更多推荐
发布评论