当前位置:网站首页>基础篇——基础项目解析
基础篇——基础项目解析
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>
边栏推荐
- NAS and San
- Common functions of go-2-vim IDE
- 华为设备配置信道切换业务不中断
- 【tcp】服务器上tcp连接状态json形式输出
- 函数///
- Question bank and answers of special operation certificate examination for main principals of hazardous chemical business units in 2022
- 四部门:从即日起至10月底开展燃气安全“百日行动”
- Paradigm in database: first paradigm, second paradigm, third paradigm
- BOM//
- Review the whole process of the 5th Polkadot Hackathon entrepreneurship competition, and uncover the secrets of the winning projects!
猜你喜欢
9、 Disk management
Web3 Foundation grant program empowers developers to review four successful projects
【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
关于 “原型” 的那些事你真的理解了吗?【上篇】
Basic testing process of CSDN Software Testing Introduction
csdn软件测试入门的测试基本流程
如何将 DevSecOps 引入企业?
matlab cov函数详解
【广告系统】Parameter Server分布式训练
2022鹏城杯web
随机推荐
【tcp】服务器上tcp连接状态json形式输出
2022鹏城杯web
风控模型启用前的最后一道工序,80%的童鞋在这都踩坑
R3Live系列学习(四)R2Live源码阅读(2)
微信核酸检测预约小程序系统毕业设计毕设(7)中期检查报告
跨页面通讯
如何让全彩LED显示屏更加节能环保
关于vray5.2怎么关闭日志窗口
Solution to the length of flex4 and Flex3 combox drop-down box
使用GBase 8c数据库过程中报错:80000502,Cluster:%s is busy,是怎么回事?
Nine degrees 1480: maximum ascending subsequence sum (dynamic programming idea for the maximum value)
Go-3-the first go program
PWA (Progressive Web App)
Go language-1-development environment configuration
关于vray 5.2的使用(自研笔记)
变量///
不要再说微服务可以解决一切问题了!
Question bank and answers of special operation certificate examination for main principals of hazardous chemical business units in 2022
Advanced scaffold development
2022 t elevator repair operation certificate examination questions and answers