SpringBoot Starter Introduction#
What Is The SpringBoot Starter?#
Spring boot startersis one of the major key features or components of Spring Boot Framework. The main responsibility of Spring boot stater is to combine a group of common or related dependencies into single dependencies.- Major advantanges of
Spring boot Stater: Spring boot staterreduces defining many dependencies simplify project build dependencies.Spring boot statersimplifies project build dependencies.- Ex: To develop a spring WebApplication with Tomcat webserver, we need to add some dependencies and below into Maven's
pom.xmlfile.- Spring core jar file.
- Spring web jar file.
- Spring web MVC jar file.
- Servlet jar file.
- So, if we add "spring-boot-stater-web" jar file dependency to our build file, then spring boot framework will automatically download all required jars and add to our project classpath.
- As you can see in the image below,
Spring Boot Staterhas a dependency onSpring Boot AutoConfigurator, so theSpring Boot Staterwill triggersSpring Boot AutiConfiguratorautomatically.
@SpringBootApplication And SpringApplication Class#
- In Spring Boot project, we usually see a main class which uses
@SpringBootApplicationandSpringApplication classas below
| Application.java | |
|---|---|
1 2 3 4 5 6 7 8 9 10 | |
- So as we learned above
@SpringBootApplicationannotation is used to mark a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning. It's same as declaring a class with@Configuration,@EnableAutoConfigurationand@ComponentScanannotations. SpringApplicationclass is used to bootstrap and launch a spring application from a Java main method. This class automatically create theApplicationContextfrom the classpath, scan the configuration classes and launch the application. This class is very helpful in launching Spring MVC or Spring REST application using Spring Boot.
