SpringBoot一分钟快速入门,摆脱SSM配置地狱!

 使用 IDEA 直接创建项目

1、创建一个新项目

2、选择spring initalizr

 选择初始化组件Web

 等待项目构建成功

在com.longdi.helloworld包下新建一个HelloController类

package com.longdi.helloworld.controller;

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

/**
 * @author: 龍弟
 * @description
 * @date: 2021/9/29 13:03
 */
@RestController
public class HelloController {
    //接口:http://localhost:8080/hello
    @RequestMapping("hello")
    public String hello(){
        //调用业务,接收前端的参数
        return "hello world";
    }
}
复制代码

项目结构

 启动项目,即可在浏览器显示HelloWorld!

http://localhost:8080/hello

只需要几步,就可以完成一个web接口的开发,SpringBoot就是这么简单

将项目打成jar包,点击 maven的 package

 如果打包成功,则会在target目录下生成一个 jar 包

打成了jar包后,就可以在任何地方运行了!

 如何更改启动时显示的字符拼成的字母,也就是 banner 图案

只需一步:到项目下的 resources 目录下新建一个banner.txt 即可。

SpringBoot操作起来如此简单,我们之后去进行一波源码研究分析!

欢迎来我的Github: github.com/dragon-idea

猜你喜欢

转载自juejin.im/post/7034769305942097933