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
Spring Initializr -> JDK version -> Next
Group -> Artifact -> Description
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
Creating Controller
Right-click -> New-> Java Class
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
access
to sum up
```
- The main program will be automatically generated, just write logical file
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;The directory structure created automatically