InterviewSolution
| 1. |
What are Spring Boot Starters? |
|
Answer» Spring Boot starters help you to avoid defining a set of dependency descriptors. Spring Boot Starters automatically includes the required dependencies for the said feature so that you don't have to go through the cumbersome process of defining the dependencies in your application. Beyond the EASE of dependency descriptors, it ALSO relieves you from a lot of boilerplate code. Thus, when you include the Starters you do not need to hunt through sample code and copy-paste dependency descriptors. Secondly, Spring Boot Starters also give you initial setup or initialization of the said feature. This enables the developer to get quickly started on the new feature. Let’s try to understand this with an example: You have a requirement to develop a new application that exposed REST endpoints for the user. It also has a requirement to connect to a DATABASE for fetching data. Let’s try to simulate this without Spring Boot first. In this case, you will need to add dependencies for Spring MVC, Jackson. You will also need to download and install Tomcat Web Server where you can deploy this new application. Additionally, you also need to configure Tomcat in your favourite IDE ( Eclipse or any other IDE) so that you can run the application from IDE itself. So many things, right? With Spring Boot around, you can just add a dependency for Spring Boot Web Starter and you are done. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>You can annotate your classes with @RestController , @RquestMapping, @GET, @POST as Spring Rest library has been imported . You can just run application as Spring Boot mode and it will use embedded Tomcat Server to deploy your application , your application will be up and running at localhost:8080. |
|