Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does @SpringBootApplication actually work in spring boot?

I don't understand how the SpringBootApplication shortcut works. Specifically I don't understand how the individual sub annotations like @ComponentScan and @EnableAutoConfiguration get passed onto the actual application class as if they were written explicitly there. I searched spring boot's code base for SpringBootApplication expecting to see code that looks for the "SpringBootApplication" string before applying these individual annotations but did not see any. Can someone explain this? Thanks.

like image 721
Jack Peng Avatar asked Sep 13 '25 09:09

Jack Peng


1 Answers

The @SpringBootApplication annotation is an annotation that is annotated with, among others, the annotations @ComponentScan and @EnableAutoConfiguration you mentioned. Instead of scanning for @SpringBootApplication, Spring internally scans for these (implicit) annotations and does its magic accordingly.

like image 156
C-Otto Avatar answered Sep 14 '25 22:09

C-Otto