news 2026/4/23 9:41:06

Spring Boot 封神之路:从基础到架构,一篇吃透所有核心知识点

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Spring Boot 封神之路:从基础到架构,一篇吃透所有核心知识点

一:搭建一个SpringBoot项目

1:项目搭建

1:创建一个空项目

2:创建一个Maven模块

3:添加Parent标签

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.0.5</version> </parent>

4:添加Web场景依赖

场景启动器:

<dependencies> <!--web开发场景启动器--> <!--json/tomcat/web/webmvc都引入进来了--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>

5:添加主程序

package com.dashu; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * SpringBoot项目入口主程序 * 标注这是一个SpringBoot应用 */ @SpringBootApplication public class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class,args); } }

6:编写一个Rest请求

package com.dashu.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @GetMapping("/test/springboot") public String test(){ return "hello springboot"; } }

7:打包

<build> <plugins><plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin></plugins> </build>

mvn clean package 把项目打成可执行的jar包。【fat包】

2:特性总结

简化整合

导入相关场景,就存在先关功能

官方提供的场景:spring-boot-starter-xxx

第三方提供的场景:x-spring-boot-starter

场景一导入完事都具备。

简化开发

无序写任何配置,直接写因为即可
但是如果就是想修改配置,那么就需要引入一个applycation.properties

例如修改启动端口

SpringBoot官方提供的starter

spring-boot-starter-ws,

spring-boot-starter-websocket,

spring-boot-starter-web,

spring-boot-starter-velocity,

spring-boot-starter-validation,

spring-boot-starter-undertow,

spring-boot-starter-tomcat,

spring-boot-starter-thymeleaf,

spring-boot-starter-test,

spring-boot-starter-social-twitter,

spring-boot-starter-social-linkedin,

spring-boot-starter-social-facebook,

spring-boot-starter-security,

spring-boot-starter-remote-shell,

spring-boot-starter-redis,

spring-boot-starter-mustache,

spring-boot-starter-mobile,

spring-boot-starter-mail,

spring-boot-starter-logging,

spring-boot-starter-log4j2,

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/16 12:00:35

Python_uniapp-校园商店商城购物小程序

文章目录Python_uniapp-校园商店商城购物小程序的摘要系统设计与实现的思路主要技术与实现手段源码lw获取/同行可拿货,招校园代理 &#xff1a;文章底部获取博主联系方式&#xff01;Python_uniapp-校园商店商城购物小程序的摘要 校园商店商城购物小程序基于Python后端和Uniap…

作者头像 李华
网站建设 2026/4/18 8:54:14

Python_uniapp-鲜花商城销售系统 微信小程序

文章目录摘要系统设计与实现的思路主要技术与实现手段源码lw获取/同行可拿货,招校园代理 &#xff1a;文章底部获取博主联系方式&#xff01;摘要 Python_uniapp-鲜花商城销售系统微信小程序是一个基于Python后端和Uniapp前端框架开发的综合性电商平台&#xff0c;专注于鲜花在…

作者头像 李华
网站建设 2026/4/23 9:31:02

为什么同内容的两个目录,ls和du显示的大小不一样?

前言&#xff1a;在进行目录迁移时&#xff0c;很容易遇到一个有趣的现象&#xff1a;明明是内容完全一致的两个目录&#xff0c;用ls/ll查看目录本身的大小时&#xff0c;数值并不相同&#xff1b;但用du -sh统计目录下文件的总大小&#xff0c;结果却完全一致。这背后藏着“目…

作者头像 李华
网站建设 2026/4/16 19:33:14

通信原理篇---模拟通信系统

用送信来比喻通信系统想象一下&#xff0c;你要把一封手写的信&#xff08;模拟信号&#xff09;从你家送到朋友家。模拟通信系统 —— 相当于派一个邮差骑自行车&#xff0c;原封不动地拿着你的手写信直接送过去。信的内容是连续的字迹&#xff0c;邮差在路上可能会遇到下雨&a…

作者头像 李华