Teach you how to build a springboot program

1. Build from the official website

1. Enter the spring official website and quickly initialize a project

2. Fill in the basic information of the project

3. Project structure analysis

4. Add project dependencies


Here first integrate the spring-web package to

support restful style, and embed tomcat as the default container

5. Download to local

6. Unzip

7, idea, open, use maven to build the project

8. Build with maven

9. This is built, delete all other directories


The project runs, packs, banners, and changes ports, as described below.

Two, idea build

surroundings:

java8,maven3,idea

1. Idea build, create a springboot project

2. Fill in project information

3. Add references


Added spring-web

4. Complete the project creation

5. Finishing


Clean maven project

3. Project operation and packaging

1. Run the project

2. The console shows the version information

3. Port 8080, 404~


4. Write the controller and output helloworld

package cn.bitqian.controller;

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

/**
 * @author echo lovely
 * @date 2020/9/26 10:47
 */
@RestController
public class DemoController {
    
    

    @RequestMapping(value = "/hello")
    @ResponseBody
    public String hello() {
    
    

        return "hello world!";
    }
}

The business code (package) must be at the same level as the main entry of the program

5. Results show, elegant restful style

6. Type the project into a jar package and double-click the package


Run the cmd window

of the jar package in the target directory of the console log

java -jar springboot-02-0.0.1-SNAPSHOT.jar


Access via web

http://localhost:8080/hello

7. Follow-up, port change, banner

Modify properties

Change and start the banner
Insert picture description here
banner, it’s so delicate, I’m a big springboot

Guess you like

Origin blog.csdn.net/qq_44783283/article/details/108808163
Recommended