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

nacos 监听refresh Event 事件导致lazyInit Bean提前加载 #299

Open
huyiyu opened this issue Nov 30, 2022 · 1 comment
Open

nacos 监听refresh Event 事件导致lazyInit Bean提前加载 #299

huyiyu opened this issue Nov 30, 2022 · 1 comment

Comments

@huyiyu
Copy link

huyiyu commented Nov 30, 2022

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

我使用了 nacos-spring-boot-starter 引入了nacos-spring-context 1.1.1
部分需要lazyInit 的对象在 nacos 判断 NacosConfigListener 注解是否存在的接口上出现,具体代码
getBeanOfType方法 此处getBean导致了所有Bean都被迫创建,建议改造成 getBeanNameOfType 以及 getType 方式获取Bean的类型,这样不会加载到不应该被提前加载的累

Describe what you expected to happen

希望 @lazy 注解相关的内容不在此处创建(外部对接服务)

How to reproduce it (as minimally and precisely as possible)

  1. 为一个bean设置@lazy
  2. 观察是否在nacos 接收到spring 启动成功事件时 被放入BeanMap 变量。

Tell us your environment

  • nacos-spirng-boot-starter 0.2.12
  • jdk 8
  • windows 10

Anything else we need to know?

对于注解的扫描可以不必调用getBean ,直到确实有存在注解才去getBean 因为getBean方法在对象没有的时候会走创建逻辑

@huyiyu
Copy link
Author

huyiyu commented Nov 30, 2022

解决方案想提个pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant