idea使用Spring Initializr一键生成Spring Boot应用

首先打开idea,点击File--New--project,选中Spring Initializr,点击Next

接着继续点接Next

选择Web,然后点击Next

点击完成即可

接着创建一个controller包进行测试

在controller下创建MyController类

package com.lzy.myspringboot.controller;

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

@Controller
public class MyController {
    //RequestMapping使out方法和url中的/out地址绑定在一起,ResponseBody则会将success字符串输出到客户端浏览器
    @RequestMapping("/out")
    @ResponseBody
    public String out(){
        return "success";
    }
}

 回到MySpringBootApplication类点击运行

控制台出现

接着打开浏览器,输入localhost:8080/out,运行结果为success说明成功了

猜你喜欢

转载自blog.csdn.net/qq_41937388/article/details/90726160