Spring Boot Starter Projects
Starters are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need, without having to hunt through sample code and copy paste loads of dependency descriptors. For example, if you want to get started using Spring and JPA for database access, just include the spring-boot-starter-data-jpa dependency in your project, and you are good to go.
Spring Initializr http://start.spring.io/ is great tool to bootstrap your Spring Boot projects.
Spring Boot Starter Web
Spring Boot Starter Web brings in 2 important features
- Compatible Dependencies that are needed to develop web applications
- Auto Configuration
Dependency for Spring Boot Starter Web
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Dependencies can be classified into:
- Spring – core, beans, context, aop
- Web MVC – (Spring MVC)
- Jackson – for JSON Binding
- Validation – Hibernate Validator, Validation API
- Embedded Servlet Container – Tomcat
- Logging – logback, slf4j
Any typical web application would use all these dependencies. Spring Boot Starter Web comes pre packaged with these. As a developer, I would not need to worry about either these dependencies or their compatible versions.
Auto Configuration
Spring Boot Starter Web auto configures the basic things that are needed. To understand the features Spring Boot Starter Web brings in, lets run StudentServicesApplication.java as a Java Application and review the log.
Mapping servlet: 'dispatcherServlet' to [/]
Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
Spring Boot Starter Web auto-configures
- Dispatcher Servlet
- Error Page
- Web Jars to manage your static dependencies
- Embedded Servlet Container – Tomcat is the default
Spring Boot Starter Project Options
As we see from Spring Boot Starter Web, starter projects help us in quickly getting started with developing specific types of applications.
- spring-boot-starter-web-services – SOAP Web Services
- spring-boot-starter-web – Web & RESTful applications
- spring-boot-starter-test – Unit testing and Integration Testing
- spring-boot-starter-jdbc – Traditional JDBC
- spring-boot-starter-hateoas – Add HATEOAS features to your services
- spring-boot-starter-security – Authentication and Authorization using Spring Security
- spring-boot-starter-data-jpa – Spring Data JPA with Hibernate
- spring-boot-starter-cache – Enabling Spring Framework’s caching support
- spring-boot-starter-data-rest – Expose Simple REST Services using Spring Data REST
There are a few starters for technical stuff as well
- spring-boot-starter-actuator – To use advanced features like monitoring & tracing to your application out of the box
- spring-boot-starter-undertow, spring-boot-starter-jetty, spring-boot-starter-tomcat – To pick your specific choice of Embedded Servlet Container
- spring-boot-starter-logging – For Logging using logback
- spring-boot-starter-log4j2 – Logging using Log4j2