002_第一个SpringBoot项目

来源:互联网 发布:c 五子棋源码 编辑:程序博客网 时间:2024/05/18 16:35

新建项目

新建SB项目

这里写图片描述

这里写图片描述

建好项目后把application.properties改成application.yml

之后开始编写UserController类

package com.javamk.sbdemo.web;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController@RequestMapping("/user")public class UserController {    @GetMapping("/get/{id}")    public String get(@PathVariable Long id){        return "用户的ID是:" + id;    }}

右键debug as –> spring boot App
这里写图片描述

出现Tomcat started on port(s): 8080 (http)时,输入网址
http://localhost:8080/user/get/4

这里写图片描述

0 0
原创粉丝点击