Spring Boot

The process of creating standalone, production-grade, and easy-to-run Spring is made convenient by Spring Boot 2. Most Spring Boot applications need very little Spring configuration.

Spring Boot offer the following features:

  • Create standalone Spring applications
  • Embed Tomcat, Jetty, or Undertow directly (no need to deploy WAR files)
  • Dependency management through starters and various package manager integrations
  • Provide opinionated starter dependencies to simplify your build configuration
  • Automatically configure Spring and third-party libraries
  • Provide production-ready features
  • Absolutely no code generation and no requirement for XML configuration

With every new release of Spring Boot, versions of various dependencies of the Java ecosystem get upgraded. This is defined in the Spring Boot Bill of Materials (BOM).

Creating a microservice with Spring Boot is very simple; just add the following settings in your Maven project file (that is, pom.xml):

<properties>   
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>   
   <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>   
   <java.version>1.8</java.version>   
</properties>   
   
<dependencies>   
   <dependency>   
         <groupId>org.springframework.boot</groupId>   
         <artifactId>spring-boot-starter-jersey</artifactId>   
         <version>2.0.3.RELEASE</version>   
   </dependency>   
   
   <dependency>   
         <groupId>org.springframework.boot</groupId>   
         <artifactId>spring-boot-starter-test</artifactId>   
         <version>2.0.3.RELEASE</version>   
         <scope>test</scope>   
   </dependency>   
</dependencies>   
   
<build>   
   <plugins>   
         <plugin>   
         <groupId>org.springframework.boot</groupId>   
         <artifactId>spring-boot-maven-plugin</artifactId>   
         </plugin>   
   </plugins>   
</build>   

And an example application will look like the following snippet:

package com.example.demo;   
   
import org.springframework.boot.SpringApplication;   
import   org.springframework.boot.autoconfigure.SpringBootApplication;   
   
@SpringBootApplication   
public class DemoApplication {   
   
    public static void main(String[]   args) {   
          SpringApplication.run(DemoApplication.class,   args);   
    }   
}   

Furthermore, Spring's website offers a bootstrap page (http://start.spring.io/), where you can specify the requirements for your microservice by filling in the form with all of the dependencies you need, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset