Java SpringBoot 创建第一个应用程序 helloword

原文:https://www.cnblogs.com/wcf12220/p/10056577.html
原文:https://zhuanlan.zhihu.com/p/24957789?refer=dreawer
原文:https://spring.io/quickstart

1、用IDEA创建项目

路径:File -> New -> Project -> Spring Initializr -> 然后就是一路Next 和 一些基本信息的填写了

2、实现 打开网页显示helloword

创建一个类FirstController
代码如下:

package com.wangzc.firstspringbootproject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FirstController {
    @RequestMapping("/hello")
    public String welcome(){
        return "hello,world";
    }
}

导入包的代码也可以写成这样(黎大神讲的,我居然到忘了java的这种写法。。。。)

import org.springframework.web.bind.annotation.*;

运行项目后,游览器访问路径http://localhost:8080/hello即可

原文地址:https://www.cnblogs.com/guxingy/p/12841083.html