SpringBoot-Introduction and Getting Started-Spring01

SpringBoot-Introduction and Getting Started-Spring01

Introduction

springboot: Agile development tool

Features:

  1. No need for template configuration
  2. When integrating a third-party framework, as long as the corresponding starter dependency package is imported, it can be automatically integrated
  3. There is only one .properties configuration file by default, xml is not recommended, and .java files will be used to write configuration information later
  4. When springboot is deployed, the jar package is used, which automatically relies on the Tomcat container internally, providing multi-environment configuration
  5. The microservice framework springcloud is built on springboot

getting Started

  1. Select project type (requires networking)

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-mnR1Txty-1599752935869)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910231928542 .png)]

  1. project description

    [External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-1x1fW9kz-1599752935871)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910232153780 .png)]

  2. Select dependent packages and versions

    [External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-7eZSKwT1-1599752935872)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910232451298 .png)]

  3. Modify the dependencies in the pom.xml file, add web after the starter

    dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    
dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
  1. Write the controller

  2. package com.example.firstspringboot.controller;
    
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class TestController {
        @GetMapping("/test")
        public String test() {
            return "Hello,SpringBoot";
        }
    
    }
    
  3. Start the springboot project and run the main method

[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-8hSKfzAO-1599752935873)(/Users/chenxiwen/Library/Application Support/typora-user-images/image-20200910234826471 .png)]

Guess you like

Origin blog.csdn.net/rr18758236029/article/details/108525220