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

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

一分钟搭建Spring Boot

 

3.选择基本条件

一分钟搭建Spring Boot

 

 一分钟搭建Spring Boot

一分钟搭建Spring Boot

一分钟搭建Spring Boot

 

一分钟搭建Spring Boot

添加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

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

一分钟搭建Spring Boot

出现hello spring boot字样则成功

 

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

没有Spring Initializr

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

一分钟搭建Spring Boot

 

相关文章:

  • 2021-04-03
  • 2021-05-08
  • 2021-06-01
  • 2021-10-17
  • 2022-01-20
  • 2022-12-23
  • 2021-12-02
  • 2021-05-04
猜你喜欢
  • 2022-12-23
  • 2021-09-20
  • 2021-07-12
  • 2021-05-03
  • 2021-12-15
  • 2021-12-08
  • 2021-10-11
相关资源
相似解决方案