First, open the idea, click on File - New - project, select Spring Initializr, you click Next
Then continue to point connection Next
Select the Web, and then click Next
Click Finish to
Then create a controller package for testing
Create a class in the controller MyController
package com.lzy.myspringboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MyController {
//RequestMapping使out方法和url中的/out地址绑定在一起,ResponseBody则会将success字符串输出到客户端浏览器
@RequestMapping("/out")
@ResponseBody
public String out(){
return "success";
}
}
Click to run back to class MySpringBootApplication
Console appears
Then open the browser, type L ocalhost: 8080 / OUT, operating results for the success shows a success