Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不同spring上下文无法动态更新 #4876

Closed
linsword20 opened this issue Feb 4, 2021 · 3 comments
Closed

不同spring上下文无法动态更新 #4876

linsword20 opened this issue Feb 4, 2021 · 3 comments
Labels
area/Spring Related to Spring status/invalid This doesn't seem right

Comments

@linsword20
Copy link

Describe the bug
在spring父上下文初始化nacos,接着用xml生成子上下文,这边再配置nacos初始化,取值没问题,
但是nacos server更新以后,子上下文环境的@nacosValue无法更新值,NacosValueAnnotationBeanPostProcessor内place HolderNacosValueTargetMap存的是父上下文环境的内容,导致无法更新

Expected behavior
有没有可能spring上下文环境隔离,事件分别触发

Acutally behavior
A clear and concise description of what you actually to happen.

How to Reproduce
Steps to reproduce the behavior:

  1. 普通spring项目,通过configuration,配置@nacosPropertySource
  2. 当前上下文作为parent,new classPathXmlApplicationContext出新的子上下文
  3. 子上下文环境注入配置@nacosValue
  4. nacos服务端修改内容
  5. 内容无法动态更新

Desktop (please complete the following information):

  • OS: win10
  • Version [e.g. nacos-server 1.4.1, nacos-spring-context 1.0.0]
  • Module [config]
  • SDK []

Additional context
Add any other context about the problem here.

@KomachiSion
Copy link
Collaborator

可以自行尝试往子spring上下文中注入新的nacosConfigService。

nacos-spring-context目前不考虑这个场景。

@linsword20
Copy link
Author

nacosConfigService
注入nacosConfigService然后从这里面自己拿么?? 尴尬
现在好像Environment里面已经有了 就是反射写到对象不行

@KomachiSion
Copy link
Collaborator

不是很懂你的场景。注入到子Environment之后,有变更可能会走你注入的nacosConfigService。

具体你需要自己调研下,之前没有人提过类似的需求,目前来看Spring Cloud也不支持这样的玩法。应该算是个例的定制化需求了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Spring Related to Spring status/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants