# springboot-learn
**Repository Path**: hrbu2023/springboot-learn
## Basic Information
- **Project Name**: springboot-learn
- **Description**: springboot-学习
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-03-24
- **Last Updated**: 2026-03-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# SpringBoot介绍
金山老师的笔记: https://blog.fulfill.com.cn/course/01-java/springboot/springboot-9.html
Spring Boot 让你轻松创建独立的基于生产级别的 Spring 应用程序,这些应用程序你可以“只需运行”。我们对Spring平台和第三方库持独特观点,让你能轻松上手。大多数
Spring Boot 应用只需极少的 Spring
配置。如果你想了解某个特定版本的信息,或者如何从早期版本升级,可以查看我们维基上的[项目发布说明部分](https://github.com/spring-projects/spring-boot/wiki#release-notes)。
## 特色
- 创建独立的 Spring 应用程序
- 直接嵌入Tomcat、Jetty或Undertow(无需部署WAR文件)
- 提供有主见的“起始”依赖,简化你的构建配置
- 尽可能自动配置 Spring 和第三方库
- 提供生产准备的功能,如指标、健康检查和外部配置
- 完全不需要代码生成,也不需要XML配置
## [文档](https://docs.spring.io/spring-boot/3.5/index.html) https://docs.spring.io/spring-boot/3.5/index.html
# 开发工具
[Spring | Tools](https://spring.io/tools)



# 入门项目
## 快速搭建springmvc
### 父项目

### 创建组合项目的子项目

### 添加依赖
[spring-boot-starter-web](https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web)
使用 Spring MVC 构建网页应用(包括 RESTful)的 Starter。使用 Tomcat 作为默认嵌入式容器(已被 spring-boot-starter-webmvc 取代)
在项目中引入 spring-boot-dependencies,让项目继承自`spring-boot-starter-parent`
```xml
4.0.0org.springframework.bootspring-boot-starter-parent3.5.12com.neuedu.bootboot-01-helloworldjarboot-01-helloworldhttp://maven.apache.orgUTF-8org.springframework.bootspring-boot-starter-web
```
### main方法
```java
package com.neuedu.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Hello world!
*
*/
@SpringBootApplication
public class App
{
public static void main( String[] args )
{
SpringApplication.run(App.class ,args );
}
}
```
测试Controller
```java
package com.neuedu.boot.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class IndexController {
@RequestMapping("/index")
String index(){
return "success";
}
}
```

# 使用[Spring Initializr](https://start.spring.io/)创建项目


# 使用IDEA的插件


# 启动器
起始词是一组方便的依赖描述符,你可以在申请中包含。 你可以一站式获取所有 Spring 及相关技术,无需翻找样本代码和复制粘贴大量依赖描述符。
例如,如果你想开始使用 Spring 和 JPA 进行数据库访问,可以在项目中包含依赖关系。`spring-boot-starter-data-jpa`
起始程序包含了许多你需要快速启动项目并拥有一致且受控的可管理传递依赖所需的依赖。
| Name | Description |
|:--------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `spring-boot-starter` | Core starter, including auto-configuration support, logging and YAML |
| `spring-boot-starter-activemq` | Starter for JMS messaging using Apache ActiveMQ |
| `spring-boot-starter-amqp` | Starter for using Spring AMQP and Rabbit MQ |
| `spring-boot-starter-aop` | Starter for aspect-oriented programming with Spring AOP and AspectJ |
| `spring-boot-starter-artemis` | Starter for JMS messaging using Apache Artemis |
| `spring-boot-starter-batch` | Starter for using Spring Batch |
| `spring-boot-starter-cache` | Starter for using Spring Framework’s caching support |
| `spring-boot-starter-data-cassandra` | Starter for using Cassandra distributed database and Spring Data Cassandra |
| `spring-boot-starter-data-cassandra-reactive` | Starter for using Cassandra distributed database and Spring Data Cassandra Reactive |
| `spring-boot-starter-data-couchbase` | Starter for using Couchbase document-oriented database and Spring Data Couchbase |
| `spring-boot-starter-data-couchbase-reactive` | Starter for using Couchbase document-oriented database and Spring Data Couchbase Reactive |
| `spring-boot-starter-data-elasticsearch` | Starter for using Elasticsearch search and analytics engine and Spring Data Elasticsearch |
| `spring-boot-starter-data-jdbc` | Starter for using Spring Data JDBC |
| `spring-boot-starter-data-jpa` | Starter for using Spring Data JPA with Hibernate |
| `spring-boot-starter-data-ldap` | Starter for using Spring Data LDAP |
| `spring-boot-starter-data-mongodb` | Starter for using MongoDB document-oriented database and Spring Data MongoDB |
| `spring-boot-starter-data-mongodb-reactive` | Starter for using MongoDB document-oriented database and Spring Data MongoDB Reactive |
| `spring-boot-starter-data-neo4j` | Starter for using Neo4j graph database and Spring Data Neo4j |
| `spring-boot-starter-data-r2dbc` | Starter for using Spring Data R2DBC |
| `spring-boot-starter-data-redis` | Starter for using Redis key-value data store with Spring Data Redis and the Lettuce client |
| `spring-boot-starter-data-redis-reactive` | Starter for using Redis key-value data store with Spring Data Redis reactive and the Lettuce client |
| `spring-boot-starter-data-rest` | Starter for exposing Spring Data repositories over REST using Spring Data REST and Spring MVC |
| `spring-boot-starter-freemarker` | Starter for building MVC web applications using FreeMarker views |
| `spring-boot-starter-graphql` | Starter for building GraphQL applications with Spring GraphQL |
| `spring-boot-starter-groovy-templates` | Starter for building MVC web applications using Groovy Templates views |
| `spring-boot-starter-hateoas` | Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS |
| `spring-boot-starter-integration` | Starter for using Spring Integration |
| `spring-boot-starter-jdbc` | Starter for using JDBC with the HikariCP connection pool |
| `spring-boot-starter-jersey` | Starter for building RESTful web applications using JAX-RS and Jersey. An alternative to [`spring-boot-starter-web`](https://docs.spring.io/spring-boot/3.5/reference/using/build-systems.html#spring-boot-starter-web) |
| `spring-boot-starter-jooq` | Starter for using jOOQ to access SQL databases with JDBC. An alternative to [`spring-boot-starter-data-jpa`](https://docs.spring.io/spring-boot/3.5/reference/using/build-systems.html#spring-boot-starter-data-jpa) or [`spring-boot-starter-jdbc`](https://docs.spring.io/spring-boot/3.5/reference/using/build-systems.html#spring-boot-starter-jdbc) |
| `spring-boot-starter-json` | Starter for reading and writing json |
| `spring-boot-starter-mail` | Starter for using Java Mail and Spring Framework’s email sending support |
| `spring-boot-starter-mustache` | Starter for building web applications using Mustache views |
| `spring-boot-starter-oauth2-authorization-server` | Starter for using Spring Authorization Server features |
| `spring-boot-starter-oauth2-client` | Starter for using Spring Security’s OAuth2/OpenID Connect client features |
| `spring-boot-starter-oauth2-resource-server` | Starter for using Spring Security’s OAuth2 resource server features |
| `spring-boot-starter-pulsar` | Starter for using Spring for Apache Pulsar |
| `spring-boot-starter-pulsar-reactive` | Starter for using Spring for Apache Pulsar Reactive |
| `spring-boot-starter-quartz` | Starter for using the Quartz scheduler |
| `spring-boot-starter-rsocket` | Starter for building RSocket clients and servers |
| `spring-boot-starter-security` | Starter for using Spring Security |
| `spring-boot-starter-test` | Starter for testing Spring Boot applications with libraries including JUnit Jupiter, Hamcrest and Mockito |
| `spring-boot-starter-thymeleaf` | Starter for building MVC web applications using Thymeleaf views |
| `spring-boot-starter-validation` | Starter for using Java Bean Validation with Hibernate Validator |
| `spring-boot-starter-web` | Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container |
| `spring-boot-starter-web-services` | Starter for using Spring Web Services |
| `spring-boot-starter-webflux` | Starter for building WebFlux applications using Spring Framework’s Reactive Web support |
| `spring-boot-starter-websocket` | Starter for building WebSocket applications using Spring Framework’s MVC WebSocket support |
| 名称 | 描述 |
|:--------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `spring-boot-starter` | 核心启动功能,包括自动配置支持、日志记录和 YAML |
| `spring-boot-starter-activemq` | 使用 Apache ActiveMQ 进行 JMS 消息传递的入门 |
| `spring-boot-starter-amqp` | 使用 Spring AMQP 和 Rabbit MQ 的入门程序 |
| `spring-boot-starter-aop` | Spring AOP和AspectJ面向切面编程的入门程序 |
| `spring-boot-starter-artemis` | 使用 Apache Artemis 的 JMS 消息发送入门 |
| `spring-boot-starter-batch` | 使用春季批次的起始剂 |
| `spring-boot-starter-cache` | 使用 Spring Framework 缓存支持的 Starter |
| `spring-boot-starter-data-cassandra` | 用于使用 Cassandra 分布式数据库和 Spring Data Cassandra 的入门程序 |
| `spring-boot-starter-data-cassandra-reactive` | 用于使用 Cassandra 分布式数据库和 Spring Data Cassandra Reactive 的入门工具 |
| `spring-boot-starter-data-couchbase` | 用于使用 Couchbase 文档导向数据库和 Spring Data Couchbase 的 Starter |
| `spring-boot-starter-data-couchbase-reactive` | 用于使用 Couchbase 文档导向数据库和 Spring Data Couchbase Reactive 的 Starter |
| `spring-boot-starter-data-elasticsearch` | 用于使用 Elasticsearch 搜索和分析引擎以及 Spring Data Elasticsearch 的入门工具 |
| `spring-boot-starter-data-jdbc` | 使用 Spring Data JDBC 的入门 |
| `spring-boot-starter-data-jpa` | 使用 Spring Data JPA 搭配 Hibernate 的起始程序 |
| `spring-boot-starter-data-ldap` | 使用 Spring Data LDAP 的起始码 |
| `spring-boot-starter-data-mongodb` | 用于使用 MongoDB 文档导向数据库和 Spring Data MongoDB 的入门工具 |
| `spring-boot-starter-data-mongodb-reactive` | 用于使用 MongoDB 文档导向数据库和 Spring Data MongoDB Reactive 的入门 |
| `spring-boot-starter-data-neo4j` | 使用 Neo4j 图数据库和 Spring Data Neo4j 的起始程序 |
| `spring-boot-starter-data-r2dbc` | 使用 Spring Data R2DBC 的起始程序 |
| `spring-boot-starter-data-redis` | Starter 用于使用 Redis 键值数据存储,配合 Spring Data Redis 和 Lettuce 客户端 |
| `spring-boot-starter-data-redis-reactive` | 使用 Redis 键值数据存储,配合 Spring Data Redis 反应式和 Lettuce 客户端 |
| `spring-boot-starter-data-rest` | 使用 Spring Data REST 和 Spring MVC 在 REST 上暴露 Spring Data 仓库的起始程序 |
| `spring-boot-starter-freemarker` | 用于使用 FreeMarker 视图构建 MVC 网络应用的 Starter |
| `spring-boot-starter-graphql` | 用 Spring GraphQL 构建 GraphQL 应用的入门工具 |
| `spring-boot-starter-groovy-templates` | 使用 Groovy 模板视图构建 MVC 网页应用的入门 |
| `spring-boot-starter-hateoas` | 用于构建基于超媒体的RESTful网页应用的Spring MVC和Spring HATEOAS的入门程序 |
| `spring-boot-starter-integration` | 使用 Spring 集成的起始程序 |
| `spring-boot-starter-jdbc` | 使用 JDBC 搭配 HikariCP 连接池的入门 |
| `spring-boot-starter-jersey` | 用于使用 JAX-RS 和 Jersey 构建 RESTful 网页应用的 Starter。[`spring-boot-starter-web`](https://docs.spring.io/spring-boot/3.5/reference/using/build-systems.html#spring-boot-starter-web) 的替代方案 |
| `spring-boot-starter-jooq` | 用jOOQ访问JDBC的SQL数据库的入门工具。[`spring-boot-starter-data-jpa`](https://docs.spring.io/spring-boot/3.5/reference/using/build-systems.html#spring-boot-starter-data-jpa) 或 [`spring-boot-starter-jdbc`](https://docs.spring.io/spring-boot/3.5/reference/using/build-systems.html#spring-boot-starter-jdbc) 的替代方案 |
| `spring-boot-starter-json` | 用于读写json的起始程序 |
| `spring-boot-starter-mail` | 用于使用 Java Mail 和 Spring Framework 邮件发送支持的 Starter |
| `spring-boot-starter-mustache` | 使用 Mustache 视图构建网页应用的 Starter |
| `spring-boot-starter-oauth2-authorization-server` | 使用 Spring 授权服务器功能的起始工具 |
| `spring-boot-starter-oauth2-client` | 用于使用 Spring Security OAuth2/OpenID Connect 客户端功能的入门 |
| `spring-boot-starter-oauth2-resource-server` | 使用 Spring Security OAuth2 资源服务器功能的起始程序 |
| `spring-boot-starter-pulsar` | 使用 Spring for Apache Pulsar 的入门工具 |
| `spring-boot-starter-pulsar-reactive` | 使用 Apache Pulsar Reactive 的 Spring 起始器 |
| `spring-boot-starter-quartz` | 使用 Quartz 调度器的起始程序 |
| `spring-boot-starter-rsocket` | 构建 RSocket 客户端和服务器的入门程序 |
| `spring-boot-starter-security` | 使用 Spring Security 的起始工具 |
| `spring-boot-starter-test` | 用于测试包含 JUnit Jupiter、Hamcrest 和 Mockito 等库的 Spring Boot 应用的 Starter |
| `spring-boot-starter-thymeleaf` | 用于使用 Thymeleaf 视图构建 MVC 网页应用的 Start。 |
| `spring-boot-starter-validation` | 使用 Java Bean 验证与 Hibernate Validator 的入门 |
| **`spring-boot-starter-web`** | 使用 Spring MVC 构建网页应用(包括 RESTful)的 Starter。默认嵌入式容器使用 Tomcat |
| `spring-boot-starter-web-services` | 使用 Spring Web Services 的起始程序 |
| `spring-boot-starter-webflux` | 使用 Spring Framework 的反应式网页支持构建 WebFlux 应用的起始程序 |
| `spring-boot-starter-websocket` | 用于使用 Spring Framework 的 MVC WebSocket 支持构建 WebSocket 应用的 Starter |
# 自动配置

通过加载 META-INF/spring.factories中定义的 自动配置类


注册内嵌的Tomcat
```java
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web.servlet;
import io.undertow.Undertow;
import jakarta.servlet.Servlet;
import org.apache.catalina.startup.Tomcat;
import org.apache.coyote.UpgradeProtocol;
import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.Loader;
import org.xnio.SslClientAuthMode;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatProtocolHandlerCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Configuration classes for servlet web servers
*