IDEA创建一个SpringBoot的Demo
1.新建工程,选择Spring Initiaizer,选项默认,点击next
2.这里可以选择默认,点击next
3.选择web,勾选web,点击next
4.可以不修改内容,点击fininsh
5.工程创建成功,新建一个测试的Controller
代码如下:
package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "Hello Spring Boot!";
}
}
6.右键启动DemoApplication
7.浏览器输入http://localhost:8080/hello,验证成功