SpringBoot | 使用Spring Initializr来快速创建一个SpringBoot项目

目录

一、新建项目

二、编码

三、测试


一、新建项目

新建项目,选择Spring Initializr

 
13424350-5b0f33f0c582f137.png
 
 
13424350-d042d127ff51be53.png
 

选择模块,我们选择一个Web模块:

 
13424350-57b75ad5d9e70158.png
 
 
13424350-6a13040df0528dfc.png
 


自动给我们创建了整个目录架构:

 
13424350-9b65b48a623602b9.png
 

二、编码

新建controller包,在包中新建HelloController

package com.cerr.springboot.controller;

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

@RestController
public class HelloController {

    @RequestMapping(value = "/hello")
    public String helloWorld(){
        return "hello world springboot";
    }
}

三、测试

点击Springboot01DemoApplication类,运行main方法启动该springboot项目:

 
13424350-c70e073f131c2bb2.png
 

在浏览器中访问:

 
13424350-b5daee9b899faee3.png
 

猜你喜欢

转载自blog.csdn.net/qq_14810195/article/details/103651504