好比咱们须要查Spring Boot 2.1.4-RELEASE的内嵌Tomcat版本, 能够打开连接:java
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat/2.1.4.RELEASE
以下图, 红框标记的就是tomcat的版本。
web
目前你们主要使用IDEA来进行开发,下面是IDEA查看Tomcat的版本:spring
Gradle能够采用如下命令打印依赖项:apache
./gradlew dependencies
数据结果示例:api
... | +--- 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能够采用如下命令打印依赖项:tomcat
mvn dependency:tree > output.txt # 输出到文件里
由于SpringBoot内嵌的Tomcat会伴随SpringBoot的升级而升级,因此能够根据须要选择合适的Tomcat版本,这种特别须要升级Tomcat版本时使用,固然仍是要根据状况,由于升级SpringBoot的版本也是有成本的。springboot
有时候咱们须要在特定状况下使用特定的Tomcat版本,这时候总不能由于Tomcat就改变SpringBoot的版本,因此能够采用排除SpringBoot中的Tomcat包,而后手动指定Tomcat的版本,固然还要引入Tomcat相关的包。websocket
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版本, 不然直接指定对应的版本号。socket
在 pom.xml文件里面添加一个标签<properties>
,添加指望的版本。maven
<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>