springboot学习(一)

1、快速创建springboot项目

         打开idea工具,file-->new ----->project--->Spring Initializr

选择web型项目

填写工程名+工程保存路径

新建完项目之后结构如下:

需要编写controller,作为展示:

package com.springboottest.springboottest.controller;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@EnableAutoConfiguration
public class HelloController {

    @RequestMapping("/hello")
    public String index(){
        return "Hello world !";
    }
}

执行application

成功启动标志:

然后在浏览器输入地址URL:

http://localhost:8080/hello

展示页面数据

特别注意点:

controller 不能写到test路径下面,若是写到下面,页面会报错。

报错页面:

猜你喜欢

转载自blog.csdn.net/wantong871210/article/details/81109496
今日推荐