Spring Boot

Spring Boot is a new framework from the Pivotal team designed to simplify the initial setup and development process for new Spring applications. The framework uses a specific way to configure so that developers no longer need to define boilerplate configurations. In this way, Spring Boot aims to be a leader in the burgeoning field of Rapid Application development.

Spring Boot features:

  1. Create a stand-alone Spring application

  2. Embedded Tomcat without the need to deploy a WAR file

  3. Simplifying Maven Configuration

  4. Automatic Spring configuration

  5. Provides production-ready functions such as metrics, health checks, and external configuration

  6. There is absolutely no code generation and no configuration requirements for XML

Quick start:

1. Visit http://start.spring.io/

2. Fill in the relevant project information, JDK version, etc. (please refer to the picture below)

3, Click Generate Project to Generate a maven Project package. Download the Project package. Import -> Existing Maven Projects -> Next -> select the decompressed folder -> Finsh

Introduction to the project structure: As shown in the figure below, the Spring Boot infrastructure consists of three files:

SRC /main/ Java — program development and main program entry SRC /main/resources — configuration file SRC /test/ Java — test program

Root directory: com.example.myProject 1) domain: entity class (com.example.domain) 2) Dao: Data Access Layer (com.example.repository) 3) Service: Data access layer (com.example.repository) ServiceImpl: Data service Implementation layer (com.example.service.impl) 4) Controller: front-end Controller (com.example.controller) 5) utils: utility class (com.example.utils) 6) constant: Constant interface class (com.example.constant) 7) config: config information class (com.example.config) 8) dto: Data Transfer Object (Data Transfer Object, used to encapsulate the relationship between multiple entity classes (domain, does not destroy the original entity class structure) (com.example.dto) 9) vo: View Object (used to encapsulate the data requested by the client, prevent partial data leakage, ensure data security, and do not destroy the original entity class structure) (com.example.vo)

Introducing Web modules: Add web-enabled modules to POM.xml

1 2 org.springframework.boot 3 Spring-boot-starter -web 4 Run the project:

1. Create controller

package com.example.annewebsite_server.controller;

import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;

@RestController public class HelloController { @GetMapping(“/hello”) public String say(){ return “Hello Spring Boot!”; } }

The above is a Spring Boot project construction process, I hope to bring some help to the colleagues who are learning Spring Boot, welcome to correct the shortcomings.