第一个SpringBoot程序

1.新建一个Spring Initializr项目

基本配置

第一个SpringBoot程序

依赖支持

第一个SpringBoot程序
之后就是Maven自动导包,第一次创建会比较慢,以后创建就快了

2.了解项目目录

第一个SpringBoot程序

3.运行项目

直接点击运行,项目就可以运行了。不需要过多的配置

第一个SpringBoot程序

我们什么都没有配置,默认的界面如下

第一个SpringBoot程序

4.新建一个Controller接口

Controller(包括其他的)包要建在与程序主入口的同一个文件夹下
第一个SpringBoot程序
编写一个Controller接口

package com.google.hellospringboot.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloControlle {

    @RequestMapping("/hello")
    public String hello(){
        return "hello,world";
    }
}

在网页输入http://localhost:8080/hello

第一个SpringBoot程序

上一篇:org.springframework.context.ApplicationContextException Unable to start web server报错(已解决)


下一篇:在docker容器中操作es,并给es7.6添加用户鉴权设置密码