Exploring Spring Boot :Beginners Level

Reading Time: 4 minutes
Microservices Toolbox: Spring Boot | E4developer

What is Spring Boot

Spring Boot is a project which is built on the top of the Spring Framework. it will provide us an easier and faster way to set up likewise configure. Similarly it runs both simple and web-based applications.

Spring module provides the RAD (Rapid Application Development) feature.The Spring Framework is used to create a stand-alone Spring-based application.you can just run because it needs minimal Spring configuration.

What is Spring Boot

Likewise we can say that, Spring Boot is the combination of Spring Framework and Embedded Servers.

Similarly In Spring Boot, there is no requirement for XML configuration (deployment descriptor). however it uses convention over configuration software design paradigm.that means it decreases the effort of the developer.

Spring Boot Features :

Web Development

Spring module is perfect module for web application development We can easily create a self-contained HTTP server using embedded Tomcat, Jetty or Undertow.

Spring Application

it is an class by which You can call start your application,just by calling a static run() method.

public static void main(String[] args){  
    SpringApplication.run(className.class, args);  
}  
Application events and listeners

Spring Boot uses events to handle variety of tasks. It gives us a facility to create factories file which we can used in adding listeners. we can refer it by using ApplicationListener key.

Admin features

Spring Boot provides the facility to enable admin related features for the application. It is used to access and manage application remotely. We can enable it by simply using spring.application.admin.enabled property.

Externalised Configuration

Spring Boot allows us to externalize our configuration so that we can work with the same application in different environments. Application use YAML files to externalize configuration.

Properties Files

Spring Boot provides rich set of Application Properties. So, we can use that in properties file of our project.To set properties like: server-port = 8082 and many others we can used properties file . It helps to organize application properties.

YAML Support

It provides convenient way for specifying hierarchical configuration. It is a superset of JSON. The SpringApplication class automatically support YAML. It is successful alternative of properties.

Type-safe Configuration.

Strong type-safe configuration is provided to govern and validate the configuration of application. Application configuration is always a crucial task which should be type-safe. We can also use annotation provided by this library.

Logging

Spring Boot uses Common logging for all internal logging. Logging dependencies are managed by default. We should not change logging dependencies, if there is no required customization is needed.

Security

Spring Boot applications are spring bases web applications. So, it is secure by default with basic authentication on all HTTP endpoints. A rich set of Endpoints are available for develop a secure Spring Boot application.

Why Spring Boot?

So,you can choose Spring Framework because of the features and benefits it offers as given here −

  • Firstly,It provides a flexible way to configure Java Beans, XML configurations, and Database Transactions.
  • Secondly,It provides a powerful batch processing and manages REST endpoints.
  • Everything is auto configured in spring boot so there is no need of manual configurations .
  • Similarly,we can say that annotation-based spring application is provided by spring boot.
  • On the other hand,it offers annotation-based spring application.
  • it eases dependency management as a result
  • Therefore,it includes Embedded Servlet Container.

Advantages of Spring Boot Framework:

  • Very easy to develop Spring Based applications with Java or Groovy.
  • Minimises lots of development time and increases productivity.
  • Avoids writing lots of boilerplate Code, Annotations and XML Configuration.
  • Easy to integrate Spring Boot Application with its Spring Ecosystem like Spring JDBC, Spring ORM, Spring Data, Spring Security etc.
  • follows “Opinionated Defaults Configuration” Approach to reduce Developer effort.
  • To develop and test our web applications very easily,It Provides Embedded HTTP servers like Tomcat, Jetty etc.
  • To develop and test Spring Boot(Java or Groovy) Applications from command prompt very easily and quickly,it gives C.L.I. (Command Line Interface) tool.
  • Provides lots of plugins to develop and test Spring Boot Applications very easily using Build Tools like Maven and Gradle.
  • Gives lots of plugins to work with embedded and in-memory Databases very easily.

Disadvantages of the Spring Boot Framework

Firstly, the main struggle for many developers,when using Spring Boot is the lack of control over the system. secondly opinionated style installs many extra dependencies,it assumes the system will need.however,by installing all these extra dependencies (which sometimes go unused), the deployment binary size can become very large in Applications.
Since the framework has been built to be agile and lightweight.mainly they are focusing on APIs and micro services which are built using the framework,that’s why we should not use it for monolithic applications.
So, these facts summarise the main advantages and disadvantages of using Spring Boot.

Auto Configuration

Spring Boot Auto Configuration automatically configures your Spring application based on the JAR dependencies you added in the project. For example, if MySQL database is on your class path, but you have not configured any database connection, then Spring Boot auto configures an in-memory database.

For this purpose, you need to add @EnableAutoConfiguration annotation or @SpringBootApplication annotation to your main class file. Then, our Spring Boot application will be configured itself.

Observe the following code for a better understanding −

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

@EnableAutoConfiguration
public class DemoApplication {
   public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
   }
}

Spring Boot Starters

Handling dependency management is a difficult task for big projects. Spring Boot resolves this problem by providing a set of dependencies for developers convenience.

For example, if you want to use Spring and JPA for database access, it is sufficient if you include spring-boot-starter-data-jpa dependency in your project.

Note that all Spring Boot starters follow the same naming pattern spring-boot-starter- *, where * indicates that it is a type of the application

Examples

Look at the following Spring Boot starters explained below for a better understanding −

Spring Boot Starter Actuator dependency is used to monitor and manage your application.
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Spring Boot Starter Security dependency is used for Spring Security. Its code is shown below −
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-security</artifactId>
</dependency>
Spring Boot Starter web dependency is used to write a Rest Endpoints. Its code is shown below −
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
</dependency>
Spring Boot Starter Thyme Leaf dependency is used to create a web application. Its code is shown below −
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Spring Boot Starter Test dependency is used for writing Test cases. Its code is shown below −
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
</dependency>

Written by 

I am Intern with experience in technologies like Core Java, Advance Java and looking forward to learn and explore more into this field as well as in functional Programming. I also love competitive programming, solving live problems .

Leave a Reply