java - Why is a bean declared in @SpringBootApplication class registered even though it is not a stereotyped class? -


i have main class in project

@springbootapplication @enableoauth2sso public class app  {     public static void main(string[] args) throws exception {         springapplication.run(app.class, args);         }      @bean public requestcontextlistener requestcontextlistener(){         return new requestcontextlistener();     }  } 

as far know, component scan scans beans in stereotyped classes 1 of @component, @service, @repository, @controller if not wrong.

from spring docs

by default, classes annotated @component, @repository, @service, @controller, or custom annotation annotated @component detected candidate components.

i cannot understand how bean in class registered. not stereotyped class , no annotation annotated @component shouldn't scanned in first place code works perfectly. in fact use case having bean in class way problem solved, different thing. can please explain this. !!

@springbootapplication meta annotation looks like:

// details omitted @springbootconfiguration @enableautoconfiguration public @interface springbootapplication { ... } 

@springbootconfiguration meta annotation:

// other annotations @configuration public @interface springbootconfiguration { ... } 

and @configuration is:

// other annotations @component public @interface configuration { ... } 

it works since:

by default, classes annotated @component, @repository, @service, @controller, or a custom annotation annotated @component detected candidate components.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -