Overhead with the @SpringBootApplication annotation

The @SpringBootApplication annotation is a provision for the developers who used to annotate Spring classes with @ComponentScan, @EnableAutoConfiguration, and @Configuration. So, the @SpringBootApplication annotation is equivalent to using three annotations with default configurations. The implicit @ComponentScan annotation scans the Java classes defined in the base package (package for the Spring Boot application main class) and all subpackages. This slows down the application startup when the application has grown significantly in size.

To overcome this, we can replace the @SpringBootApplication annotation with individual annotations where we provide package paths to be scanned with @ComponentScan. We can also consider using the @Import annotation to import only the required components, beans, or configurations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset