SpringBoot - IDEA quickly create a project using Spring Initializer [four]

Foreword

Quickly create a project using Spring Initializer

step

Of course, it is to open our IDEA's editor ah ~

Create a project

File -> New -> Project

Create a project

Spring Initializr -> JDK version -> Next

Create a project

Group -> Artifact -> Description

Create a project

What modules need to choose what modules, I here only select Web Features

The final step slightly

Wait for the completion of the import module

Created

Creating Controller

Right-click -> New-> Java Class

Creating Controller

Creating Helloworld

Notes written Controller

package com.wangyang.springboot01helloworldquick.controller;

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


//@ResponseBody  //这个类的所有方法返回的数据直接写给浏览器(如果是对象转为json数据)
//@Controller

/**
 * @RestController == @ResponseBody + @Controller
 */


@RestController
public class HelloWorld {
    @RequestMapping("/hello")
    public String hello() {
        return "Hello World";
    }
}

Run the main program

Run

access

access

to sum up

```

  1. The main program will be automatically generated, just write logical file
  2. The directory structure resource file
    static: Save all static resource files such as: JS, CSS, Image;
    Templates: templates save all the pages (SpringBoot default jar package embedded Tomcat, the default does not support JSP pages)
    can use a template engine ( FreeMarker, Thymeleaf);
    the application.properties: SpringBoot application profile, can modify some of the default settings;

  3. The directory structure created automatically

Guess you like

Origin www.cnblogs.com/wangyang0210/p/11863582.html