Skip to content

nacos make spring @Lazy invalid #13150

Open
@AmmyHaber

Description

@AmmyHaber

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions