Create a Minimalist springboot project

lichengbei

2019-12-21

Visit the official website https://start.spring.io/ , fill out the basic parameters, download the project file is automatically generated

 

 

Extract the downloaded project file, and with idea to open, configure Maven , a write the Controller , run xxxApplication to

 

 

WebController.java reads as follows:

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!";
    }
}

 

使用浏览器测试:

 

 

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

Guess you like

Origin www.cnblogs.com/lichengbei/p/12079218.html