dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.5.21.RELEASE")
}
What is Spring Boot and what are its advantages
Upasana | August 05, 2019 | 2 min read | 118 views
Spring Boot makes it easy to create stand-alone, production grade Spring based applications that you can "just run" with an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss.
Main features of Spring Boot
-
Create stand-alone Spring applications (12 factor app style)
-
Embed Netty, Tomcat, Jetty or Undertow directly into executable jar (no need to deploy WAR files)
-
Provide opinionated
starter
POMs to simplify your Maven or Gradle configuration -
Automatically configure Spring whenever possible
-
Provide production-ready features such as metrics, health checks and externalized configuration
-
Absolutely no code generation and no requirement for XML configuration
-
Support for Spring 5 webflux and reactive (using project Reactor) programming in Spring Boot 2
Current version of Spring Boot as of writing this document is 1.5.21 and 2.1.6
You can create a Spring Boot starter project by selecting the required dependencies for you project using online tool hosted at https://start.spring.io/
Bare minimum dependencies for any spring boot application are:
The main java class for Spring Boot application will look something like the following:
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
You can directly run this class, without deploying it to a servlet container.
Top articles in this category:
- Spring Cloud and its advantages
- 50 microservices interview questions for Java developers
- Cracking Spring Microservices Interviews - question bank
- Is it a good practice to deploy multiple microservices in a single tomcat container
- Why Microservices are better than Monoliths
- How will you Partition a typical e-shop into Microservices Architecture