Java-- Getting to know the Springboot module for the first time

Getting to know the Springboot module for the first time

Spring Boot is a new framework provided by the Pivotal team to simplify the Spring construction and development process. With the popularity of microservice technology in recent years, Spring Boot has become a hot technology nowadays.
Spring Boot removes a large number of xml configuration files, simplifies complex dependency management, and can basically achieve automatic configuration when used with various starters. Everything that Spring can do can now be done with Spring boot.



Spring Boot Core Features

(1) Independently running Spring project
Spring Boot can run independently in the form of a jar package. To run a Spring Boot project, you only need to run it through java–jar xx.jar.


(2) Embedded Servlet container
Spring Boot can choose to embed Tomcat, Jetty or Undertow, so we don't need to deploy the project in the form of war package.


(3) Provide starter to simplify Maven configuration
Spring provides a series of starter pom to simplify Maven's dependency loading. For example, when you use spring-boot-starter-web, the dependency package shown in Figure 1 will be added automatically.


(4) Automatically configure Spring
Spring Boot will automatically configure beans for the classes in the jar package according to the jar packages and classes in the class path, which will greatly reduce the configuration we need to use. Of course, Spring Boot only considers most of the development scenarios, not all scenarios. If we need to automatically configure beans in actual development, but Spring Boot does not provide support, you can customize the automatic configuration.


(5) Quasi-production application monitoring
Spring Boot provides monitoring of runtime projects based on http, ssh, and telnet.


(6) No code generation and xml configuration
The magic of Spring Boot is not realized by means of code generation, but by conditional annotations, which is a new feature provided by Spring 4.x. Spring 4.x advocates the combination of Java configuration and annotation configuration, while Spring Boot can realize all configurations of Spring without any xml configuration.


Advantages and disadvantages of Spring Boot

(1) Advantages:

  • Quickly build projects.
  • No-configuration integrations to mainstream development frameworks.
  • The project can run independently without external dependence on the Servlet container.
  • Provides runtime application monitoring.
  • Greatly improved development and deployment efficiency.
  • Native integration with cloud computing.

(2) Disadvantages:

  • The version iteration speed is very fast, and some modules have changed a lot.
  • Since there is no need to configure it yourself, it is difficult to locate when an error is reported.
  • There are relatively few ready-made solutions online.

Implementation of simple functions:
controller controller:

package cn.zbw.controller;

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

@RestController // @RestController = @Controller + @ResponseBody
public class UserController {
    
    
    @RequestMapping("test01")
    public String test01(){
    
    
        return "你好,冰冰";
    }
}

turn out:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45686583/article/details/115302296