一分钟搭建Spring Boot

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

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

 

3.选择基本条件spring

 

 

 

添加HelloCtrl类浏览器

添加以下代码app

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.测试程序测试

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

出现hello spring boot字样则成功code

 

 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------htm

没有Spring Initializrblog

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

相关文章
相关标签/搜索