搭建Spring boot基本环境-idea

来源:互联网 发布:台风莫兰蒂数据 编辑:程序博客网 时间:2024/05/01 09:39

本人博客都是手写,如有错误,请指正。。。。
最近Spring Boot很火啊,看完基础教程,闲着没事,干脆自己动手搭建一个基本sb环境玩玩。

先用截图创建一个Spring Boot项目吧

第一步

第二步

第三步

第四步

第五步

介绍

到这儿,我们的SB项目就创建完成了,现在走一个hello world玩玩。

  1. 在我们的demo包下建一个web包,新建一个类,HelloController

    HelloController代码如下:

package com.example.demo.web;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * Created by zhoufei on 2017/8/28. */@RestController   //@RestController注解相当于@Controller注解+@ResponseBody注解,就是返回JSON喽@RequestMapping("/")public class HelloController {    @GetMapping("/hello")    public String hello(){        return "hello world";    }}

启动一下DemoApplication
访问 http://localhost:8080/hello
得到如下页面
succ

大功告成!!!!!!!