Spring-boot初始化创建(一)

这里使用idea来快速创建一个spring-boot的项目,来体验下idea之美。

new Project.

选择Spring Initializr 后开始选择包名。

这里勾选Web

 到这里就基本完成创建了。

然后找到启动文件,直接启动就行。

启动后,可以看到控制台。

并且可以输入http://localhost:8080/ 看到报错页面,这里报错是因为没有找到页面,不过可以确定web项目确实已经搭建起来了。

 这里随便创建一个控制器。

package com.sun.demo2.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping(value = "hello")
    public String Hello(){
        return "hello world";
    }
}

  运行spring-boot 在url 输入 http://localhost:8080/hello

看到的效果便是。

猜你喜欢

转载自www.cnblogs.com/sunxun/p/10099713.html
今日推荐