一、SpringBoot简介
SpringBoot是由Pivotal团队提供的全新框架,其设计目的是用来简化Spring应用的初始搭建以及开发过程。
Spring程序缺点: 配置繁琐,依赖设置繁琐
SpringBoot程序优点: 自动配置, 起步依赖(简化依赖配置), 辅助功能(内置服务器,……)
二、SpringBoot入门案例
步骤一、1.创建模块,选择Spring 初始化 并配置模块基础信息
步骤二、 2.添加起步依赖/ 选择当前模块需要使用的技术集 web Springweb
3.编写控制器;
编写功能类:
package com.example.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/books")
public class BookController {
@GetMapping("/{id}")
public String getById(@PathVariable Integer id){
System.out.println();
System.out.println();
System.out.println("id ==> "+id);
return "hello , spring boot!";
}
}
4.运行application类;
执行启动程序
测试成功:
基于idea开发SpringBoot程序需要确保联网且能够加载到程序框架结构。
SpringBoot程序启动:SpringBoot在创建项目时,采用jar的打包方式。SpringBoot的引导类是项目的入口,运行main方法就可以启动项目