1.首先你的电脑需要安装jdk、Apache Maven、Intellij IDEA

2.新建项目  (敲重点,有的同学有没有Spring Initializr 这个请到本文章后面看安装步骤

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

一分钟搭建Spring Boot 随笔 第1张

 

3.选择基本条件

一分钟搭建Spring Boot 随笔 第2张

 

 一分钟搭建Spring Boot 随笔 第3张

一分钟搭建Spring Boot 随笔 第4张

一分钟搭建Spring Boot 随笔 第5张

 

一分钟搭建Spring Boot 随笔 第6张

添加HelloCtrl类

添加如下代码

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

@Controller//这是一个控制器
public class HelloCtrl
{
    @RequestMapping("/")//将地址映射到 / 即访问http://localhost:8080 就可以进入这个方法
    @ResponseBody//返回数据,如果不添加该注解将在resources/templates下寻找与之对应的html模版
    public String hello()
    {
        return "hello spring boot";
    }
}

4.测试程序

一分钟搭建Spring Boot 随笔 第7张

打开浏览器,http://localhost:8080

一分钟搭建Spring Boot 随笔 第8张

出现hello spring boot字样则成功

 

 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

没有Spring Initializr

1.【file】->【Settings】->【Plugins】

一分钟搭建Spring Boot 随笔 第9张

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄