In this article, we'll discuss why spring boot being a favorite for a while now.
About Spring Boot
Spring Boot is built on top of the established spring framework. So, it provides all the features of spring and is ultimately easier to use than spring.
Spring got your back !!
Spring Boot helps developers to start coding right away without wasting time on preparing and configuring the environment. In contrast to other Java frameworks, it provides flexible XML configurations, robust batch processing, database transactions, and easy workflow, along with a wide variety of tools for development.
Oh, My it was Auto-configured :-0
Unlike spring everything in spring boot is auto-configured.
We need to include a set of annotations and configurations to satisfy the functionality.
Example : @Table and got more !!
Its / Easy :-)
Creating a REST API is an easy task in Spring Boot.
Annotations : @RestController, @RequestMapping are used to create an end point.
@RestController
@RequestMapping(value = "/v1")
Wait a Sec, Deployed :-||
War or jar files can be directly deployed on the Tomcat Server easily and Spring Boot provides the facility to convert our project into war or jar files. Also, the instance of Tomcat can be run on the cloud as well.
MBA(Not a Master of Business Administration) ;-}
Unlike Monolithic Architecture, the Microservice Based Architecture, as the name suggests is the name given to a module/service which focuses on a single type.
Wanna set port to 9696.
Spring Boot provides a rich set of Application Properties(which are application.properties or application.yml). we can use that in the properties file of our project.
server:
port: 9696
You are Logged.
Spring Boot uses Common logging for all internal logging using slf4j(The Simple Logging Facade for Java). Logging dependencies are managed by default.
@slf4j
class whySpring{
someFunction(){
log.info("This is printed in console, when application is running");
}
}
Web Development
It is a well-suited Spring module for web application development. We can easily create a self-contained HTTP server using embedded Tomcat, Jetty, or Undertow. We can use the spring-boot-starter-web module to start and run the application quickly.
Just run by run()
It is a class that provides a convenient way to bootstrap a Spring application which can be started from the main method. You can call start your application just by calling a static run() method.
@SpringBootApplication
public static void main(String[] args){
SpringApplication.run(whySpring.class, args);
}
Like a throne, it was Secured
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 developing a secure Spring Boot application.
Built through tools
The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies. You can manage the dependencies by using the appropriate adding dependency from the central repo to your build.gradle file.
build.gradle
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.2.4.release'
Testing was easy
As spring boot uses some additional dependencies, the testing was easier in spring boot than in spring. The test classes are advised to annotate with @SpringBootTest.
// whySpringTest.class
@SpringBootTest
class TestThatClass
{
//Test Cases
}
Final Words
In the long and short, spring boot reduces the boilerplate configuration required, by freeing developers, Hence it is popular.