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 make spring @Lazy invalid #13150

Open
AmmyHaber opened this issue Mar 4, 2025 · 2 comments
Open

nacos make spring @Lazy invalid #13150

AmmyHaber opened this issue Mar 4, 2025 · 2 comments
Labels

Comments

@AmmyHaber
Copy link

AmmyHaber commented Mar 4, 2025

Describe the bug
I set up global lazy init in springboot application builder and run it.
code like this: new SpringApplicationBuilder(TestWebApp.class).lazyInitialization(true).run(args);

but I find nacos call org.springframework.beans.factory.ListableBeanFactory#getBeansOfType(java.lang.Class<T>, boolean, boolean) method at com.alibaba.nacos.spring.context.event.AnnotationListenerMethodProcessor#processBeans(org.springframework.context.ApplicationContext), the getBeansOfType method init all beans,and it take a long time.

Expected behavior
nacos can follow the @Lazy.

Actually behavior
nacos get all beans, then all beans init.

How to Reproduce
Steps to reproduce the behavior:

  1. create a springboot application
  2. set up global lazy init
  3. run it
  4. see the CPU profile, you can see nacos take a long time to process beans.

Desktop (please complete the following information):

  • OS: Macos 15
  • Version [nacos-spring-context 1.1.1]
  • Module [config]
  • SDK [nacos]

Additional context
there are two CPU profile html file to compare with global lazy and no lazy.

cpu_profiles.zip

@KomachiSion
Copy link
Collaborator

Whether someone in community wanted to contribute for this issue?

@SteafanMrZhou
Copy link
Contributor

Whether someone in community wanted to contribute for this issue?

I can try it.

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

No branches or pull requests

3 participants