当前位置:网站首页>基础篇——基础项目解析
基础篇——基础项目解析
2022-07-05 10:46:00 【printf('小白');】
- SpringBoot优点
- 起步依赖 (简化依赖程序)
自动配置 (简化工程相关配置)
辅助功能(内置服务器, …)
- 起步依赖 (简化依赖程序)
parent
spring-boot-dependencies-2.6.1.pom中定义了很多个版本和坐标关系
- 阿里云创建版本直接引用了
spring-boot-dependencies
(继承只能用一次) 避免多个依赖使用相同的技术时出现版本冲突
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
可以只写GA不用写V
- 遇到错误之后再加入V版本信息,但是要
小心版本冲突
starter
- 一个starter提供了一个技术所需的各种依赖,达到
减少依赖配置的目的
- 简化配置的目的
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
引导类
- 引导类是Boot工程的执行入口,运行main方法就可以启动项目
- SpringBoot工程运行后初始化Spring容器,扫描引导类所在包加载Bean
@SpringBootApplication
public class Springboot0101QuickstartApplication {
public static void main(String[] args) {
ConfigurableApplicationContext run = SpringApplication.run(Springboot0101QuickstartApplication.class, args);
BookController bean = run.getBean(BookController.class);
System.out.println("book--==>"+ bean);
User bean1 = run.getBean(User.class);
System.out.println("User--==>"+ bean1);
}
}
内嵌tomcat
- SpringBoot内置一个tomcat服务器
- 可以从starter-web中排除换成其他的服务器,例如下面案例中的
jetty
- 常见的内置服务器
- apache出品,粉丝多,
应用面广
,负载了若干较重的组件
jetty更轻量级
,负载性能远不及tomcat
undertow 负载性能勉强跑赢tomcat
- apache出品,粉丝多,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
边栏推荐
- DGL中的消息传递相关内容的讲解
- 赛克瑞浦动力电池首台产品正式下线
- GBase 8c数据库如何查看登录用户的登录信息,如上一次登录认证通过的日期、时间和IP等信息?
- About the use of Vray 5.2 (self research notes)
- Paradigm in database: first paradigm, second paradigm, third paradigm
- 一次edu证书站的挖掘
- Variables///
- 脚手架开发进阶
- 2022 chemical automation control instrument examination questions and online simulation examination
- Wechat nucleic acid detection appointment applet system graduation design completion (7) Interim inspection report
猜你喜欢
一次edu证书站的挖掘
九、磁盘管理
About the use of Vray 5.2 (self research notes)
关于vray 5.2的使用(自研笔记)(二)
Web3 Foundation grant program empowers developers to review four successful projects
基于昇腾AI丨以萨技术推出视频图像全目标结构化解决方案,达到业界领先水平
Basic testing process of CSDN Software Testing Introduction
关于vray 5.2的使用(自研笔记)
如何让全彩LED显示屏更加节能环保
2022 chemical automation control instrument examination questions and online simulation examination
随机推荐
websocket
vite//
【Oracle】使用DataGrip连接Oracle数据库
Wechat nucleic acid detection appointment applet system graduation design completion (6) opening defense ppt
Bracket matching problem (STL)
数据类型、
Go language learning notes - first acquaintance with go language
LSTM applied to MNIST dataset classification (compared with CNN)
Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
regular expression
赛克瑞浦动力电池首台产品正式下线
Buried point 111
C语言活期储蓄账户管理系统
不要再说微服务可以解决一切问题了!
Operators
括号匹配问题(STL)
磨砺·聚变|知道创宇移动端官网焕新上线,开启数字安全之旅!
NAS and San
如何将 DevSecOps 引入企业?
中职组网络安全C模块全漏洞脚本讲解包含4个漏洞的脚本