演示代码地址:kuizuo/spring-boot-demo (github.com)
目录结构展示图
controller
controller 目录下对应的也就是控制器,用于接收用户的请求(get,post 等),如下面代码
controller/UserController.javajava
@RestController
@RequestMapping("/user")
public class UserController {
@Resource
private UserService userService;
@GetMapping("list")
public List<User> list() {
return userService.findAll();
}
}