通过官网创建运行一个最简单的springboot项目

lichengbei

2019-10-20

1.登录官网https://start.spring.io/填写基本参数,下载自动生成的项目文件

 2.解压下载好的项目文件,并用idea打开,配置好maven,写一个controller,运行xxxApplication即可

 WebController.java的内容如下:

package com.forest.fox.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@ResponseBody
public class WebController {
    /**
     * 测试:http://127.0.0.1:8080/hello-world
     *
     * @return 测试数据
     */
    @RequestMapping(value = "/hello-world", method = RequestMethod.GET)
    public String helloWorld() {
        return "Hello World!";
    }
}

3.使用浏览器测试:

 到此,一个最简单的springboot项目已经搭建完成了。

猜你喜欢

转载自www.cnblogs.com/lichengbei/p/11707940.html
今日推荐