Performance: Why annotations drive Spring Boot
MEDIUM IMPACT
Annotations in Spring Boot affect application startup time and runtime configuration processing, impacting initial load speed and responsiveness.
@SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
@ComponentScan(basePackages = {"com.example"})
@Configuration
public class AppConfig {
@Bean
public Service service() {
return new ServiceImpl();
}
}| Pattern | Classpath Scanning | Reflection Calls | Startup Delay | Verdict |
|---|---|---|---|---|
| Broad @ComponentScan | High (many packages) | High (many classes) | High (hundreds ms) | [X] Bad |
| @SpringBootApplication with defaults | Low (default package) | Moderate (only needed classes) | Low (tens ms) | [OK] Good |