SpringBoot创建第一个Web项目——Hello SpringBoot

用idea开发工具快速创建

创建项目组、项目名和项目的包

添加web依赖

然后完成即可,可以看到如下的目录结构,而且可以直接运行

下面我们写一个controller

package com.hzy.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String show() {
        return "Hello SpringBoot";
    }
}

然后启动该项目,访问http://localhost:8080/hello 

发布了423 篇原创文章 · 获赞 273 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/HeZhiYing_/article/details/104323146