“This is my 8th day of the November Gwen Challenge.The final text challenge in 2021”.

preface

I asked my colleagues and students in Java backend development, and almost all backend development is using SpringBoot. Of course we’re using it in our current project, but in the spirit of “roll them up or let them roll you down,” we decided to take a closer look at SpringBoot core technologies and responsive programming

The official website is:

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".

Translation:

SpringBoot makes it easy to create stand-alone, production-grade, Spring-based applications that you can “run straight.”

The advantages of SpringBoot

  • Quickly create an independentSpringapplication
  • embeddedwebThe server
  • Community active, automatedstarterRely on rich, easy to integrate
  • Provides production-level monitoring, health checks, and externalized configuration
  • Simplify configuration without writing a large number of configuration files.

HelloWorld

Starting with HelloWorld, create a HelloWorld application using SpringBoot

  • new ProjectuseSpring InitializrQuickly createSpringBootproject

  • Click on thenextchooseSpringBootVersion, addwebTo develop dependencies, clickfinish

  • At this point, a SpringBoot application has been created. So far, we haven’t written a single line of code, and we haven’t added a single configuration file.

  • Create a Controller package and write a simple Hello interface

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String helloWorld(a) {
        return "The helloWorld!"; }}Copy the code
  • And we can see,IDEAThe startup class is automatically generated for usHelloworldDemoApplication, click Run.

The console displays that the operation succeeds and the default port number is 8080.

  • Browser access

The interface responded successfully.

Here, we should be able to feel the convenience of SpringBoot, we do not have to configure cumbersome configuration files, and even do not have to configure external servers, do not have to manually import dependencies, all of the Internal SpringBoot help us to do, we can put more energy on our code logic and business logic.

The configuration file

SpringBoot simplifies a lot of configuration files. By default, there is a unified application.properties configuration file that allows you to configure information such as port numbers for service startup.

Please refer to the official documentation for details