惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
V
V2EX
Cloudbric
Cloudbric
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
量子位
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
K
Kaspersky official blog
博客园 - 【当耐特】
T
Tenable Blog
L
Lohrmann on Cybersecurity
The Cloudflare Blog
S
Schneier on Security
A
Arctic Wolf
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
罗磊的独立博客
T
The Exploit Database - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
雷峰网
雷峰网
NISL@THU
NISL@THU
人人都是产品经理
人人都是产品经理
月光博客
月光博客
J
Java Code Geeks
V
Visual Studio Blog
S
Security Affairs
博客园 - Franky
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Heimdal Security Blog
有赞技术团队
有赞技术团队
V2EX - 技术
V2EX - 技术
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
T
Troy Hunt's Blog
SecWiki News
SecWiki News
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 聂微东

博客园 - 光脚码农

CentOS安装JDK CentOS 7中安装和配置Promethues - 光脚码农 - 博客园 CentOS中安装Azkaban 2.5 Centos7 安装Nodejs SpringBoot实用技巧札记 SQL实用札记【SQL Sever篇】 话说静态构造函数 如何利用正则表达式匹配花括号内的内容 如何为Windows Forms应用程序添加启动参数(Start-Up Parameters) 利用存储过程来重命名SQL Server数据库 .NET批量操作窗口样式 ViewData、ViewBag、TempData、Session的区别与联系 如何为自己的网页实现一个“回到顶部”的链接? 如何获得数据库中所有用户创建的索引 如何为一个类型为Color的属性设置默认值 用BCP从SQL Server 数据库中导出Excel文件 DataGridView如何绑定DataRow对象集合 Const vs. Readonly Windows下Git的安装与配置(Cygwin)
查看和指定SpringBoot内嵌Tomcat的版本 - 光脚码农 - 博客园
光脚码农 · 2019-04-29 · via 博客园 - 光脚码农

查看当前使用的Tomcat版本号

Maven Repository中查看

比如我们需要查Spring Boot 2.1.4-RELEASE的内嵌Tomcat版本, 可以打开链接:

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat/2.1.4.RELEASE

如下图, 红框标记的就是tomcat的版本。

查看dependepency

透过IDE

目前大家主要使用IDEA来进行开发,下面是IDEA查看Tomcat的版本:

透过命令行

Gradle可以采用以下命令打印依赖项:

./gradlew dependencies

数据结果示例:

...
|    +--- org.springframework.boot:spring-boot-starter-tomcat:2.1.0.RELEASE
|    |    +--- javax.annotation:javax.annotation-api:1.3.2
|    |    +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.12
|    |    +--- org.apache.tomcat.embed:tomcat-embed-el:9.0.12
|    |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.12
|    |         \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.12
...

Maven可以采用以下命令打印依赖项:

mvn dependency:tree > output.txt   # 输出到文件里

指定SpringBoot项目内嵌的Tomcat版本

直接升级SpringBoot的版本

因为SpringBoot内嵌的Tomcat会伴随SpringBoot的升级而升级,所以可以根据需要选择合适的Tomcat版本,这种特别需要升级Tomcat版本时使用,当然还是要根据情况,因为升级SpringBoot的版本也是有成本的。

排除SpringBoot的Tomcat,指定Tomcat版本

有时候我们需要在特定情况下使用特定的Tomcat版本,这时候总不能因为Tomcat就改变SpringBoot的版本,所以可以采用排除SpringBoot中的Tomcat包,然后手动指定Tomcat的版本,当然还要引入Tomcat相关的包。

Gradle的配置
compile('org.springframework.boot:spring-boot-starter-web') {
    exclude module: "spring-boot-starter-tomcat"
}
compile 'org.apache.tomcat.embed:tomcat-embed-core:+'
compile 'org.apache.tomcat.embed:tomcat-embed-el:+'
compile 'org.apache.tomcat.embed:tomcat-embed-logging-juli:+'
compile 'org.apache.tomcat.embed:tomcat-embed-websocket:+'

如果不指定版本,则会使用最新的Tomcat版本, 否则直接指定对应的版本号。

Maven的配置

在 pom.xml文件里面添加一个标签<properties>,添加期望的版本。

<tomcat.version>8.0.30</tomcat.version>

添加必要的Jar包:

<dependency> 
   <groupId>org.apache.tomcat</groupId> 
   <artifactId>tomcat-juli</artifactId> 
   <version>${tomcat.version}</version> 
 </dependency>
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-logging-juli</artifactId>
    <version>${tomcat.version}</version>
</dependency>