1.

Explain Different features of Spring Boot.

Answer»

FOLLOWING are the features of Spring Boot :

  • AutoConfiguration 

Spring Boot scans the libraries available on the also scans existing configuration for the given application and then provides default configuration ( going by convention) for the library with Application. Think of this as it actually initializes library on the classpath with default values. These libraries are nothing but Spring Boot Starters which may execute some code on startup as well.

For example, when you include a spring boot starter web dependency, from a coding point of view you will see spring mvc is available to you so that you can define REST endpoints or so, you can import @RestController, @RequestMapping etc to build REST endpoints for the application. 

However, from an application point of view, you will set that at startup, dispatcherservlet and a default error page is autoconfigured. What’s more, embedded Tomcat is configured to run at default port 8080 and application gets deployed at 8080. 

So see how Spring Boot MAKES life easy for Developers! 

Now, the DEVELOPER needs to think about SETTING up web.xml or setting up a Tomcat server. He/She can concentrate on an actual application which is drafting REST endpoints & writing Business Logic.

This example was with respect to Web dependency but the same is true for each and every dependency. This is helpful even in case of Proof of Concept carried out by Developers as configuration work is minimized because of AutoConfiguration.

  • Starters libraries

Spring Boot starter libraries is a list of dependency Starters that gets you (quick)        

started on using a particular feature in the application. A starter library is nothing but a wrapper built around the dependency libraries. It is a one-stop-shop for the feature & takes care of including the required dependencies.  It basically carries out 2 things for you :

  • First, of course, gets all the dependencies required ( Dependency Management for that Feature)
  • The Starters generally comes with initialization code assuming few defaults to get you started quickly.
Advantages of Using Spring Boot Starters :
  • The Dependency configurations & the starter itself are well tested and production-ready
  • Eases pom manageability
  • Decreases the Boilerplate code to a large extent
  • Decreases the application Configuration to a large extent.
  • Spring Boot Command Line interface

Spring Boot CLI lets you WRITE & run Groovy Scripts.

For example, let’s assume the following content in app.groovy

@RestController class GroovyScript { @RequestMapping("/") String home() { "Welcome to Spring Boot!" } }

You can then run this as 

spring run app.groovy

Visit localhost:8080 to see the Welcome Message.

  • Actuator

The actuator provides built-in features to your application which are production-ready. It provides web endpoints for each of this feature. Some of the most common Spring Boot Actuator endpoints:

  • /health: It shows application health information
  • /beans: It lists all Spring beans in your application
  • /trace: It shows trace information for last few HTTP requests
  • /env: Displays a list of properties in the current environment
  • /info: It shows arbitrary application info
  • /metrics: It shows all metrics related information for the current application
  • /threaddump: Performs thread dump.


Discussion

No Comment Found