Learning a spring-boot: Spring boot quickly create a project using the Spring Initializr

  We can quickly create a Spring boot project by IDEA, concrete steps are as follows:

1. Open IDEA-> Select File -> NEW-> project;

2. Select the left side of the module Spring Initializr, select JDK. Then click next;

3. The content of the following page after filling is complete click next;

Back all the way next, the best since a project name;

Click Finish to finish the project directory is created as follows:

There is no content can be used to delete, from deleted directory structure as follows:

 Here we explain its directory structure:

[1] In the main package has helped us build the main program category;

[2] Now that the main program has been good, then we create a new controller, to achieve the next business function logic;

package com.hai.bao.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author :haibao.wang
 * @date :Created in 2019/8/27 21:51
 * @description:实现在 Web 前端返回 hello Spring的功能
 * @modified By:
 * @version: $
 */
@ResponseBody
@Controller
public class HelloSpring {
    @RequestMapping("helloSpring")
    public String toString() {
        return "hello Spring";
    }
}

The expansion of knowledge: where @ResponseBody and @Controller two notes can be combined into a comment: @RestController;

[3] directory structure as follows:

Resources directory file: static folder: store static resource files, such as js / css / images;

                                      templates folder: templates save all the pages;

          application.properties File: spring boot default profile can be modified some default configuration, such as port numbers;

Finally, we perform our written Controller

 

Guess you like

Origin www.cnblogs.com/haibaowang/p/11421069.html