简体   繁体   English

如何知道spring boot中嵌入了哪个tomcat版本

[英]How to know which tomcat version embedded in spring boot

I used spring boot in project.我在项目中使用了弹簧靴。 It has inbuild tomcat server.它有内置的 tomcat 服务器。 I find out a jar spring-boot-starter-tomcat-1.2.5.RELEASE.jar .我找到了一个 jar spring-boot-starter-tomcat-1.2.5.RELEASE.jar I required to do certain tomcat related configuration on linux server.我需要在 linux 服务器上做一些与 tomcat 相关的配置。

How can I get to know which tomcat version used in this?我怎样才能知道这里使用的是哪个 tomcat 版本?

You can also check the version without leaving your IDE by seeing the effective pom.您还可以通过查看有效的 pom 来检查版本,而无需离开您的 IDE

For example, if you are using IntelliJ you can view effective pom by right clicking pom.xml > Maven > Show effective POM .例如,如果您使用 IntelliJ,您可以通过右键单击pom.xml > Maven > Show Effective POM 来查看有效的 pom。

...or from the command line by issuing mvn help:effective-pom ...或从命令行发出mvn help:effective-pom

or For Gradle print the dependepency tree via the console with或者对于 Gradle 通过控制台打印依赖树

./gradlew dependencies

Example snippet from output:来自输出的示例片段:

...
|    +--- 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
...

In my example above it is tomcat version 9.0.12在我上面的例子中,它是 tomcat 版本9.0.12

You can look at http://mvnrepository.com/ :你可以看看http://mvnrepository.com/

http://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat/1.2.5.RELEASE http://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat/1.2.5.RELEASE

Below you have section Compile Dependencies and you can see that it uses Tomcat 8.0.23 .下面是Compile Dependencies部分,您可以看到它使用Tomcat 8.0.23

You can check the versions of all the dependencies in the dependency tree.您可以在依赖树中查看所有依赖的版本。

for that:为了那个原因:

  • go to the directory of pom.xml进入 pom.xml 目录
  • run the following command:运行以下命令:

    $ mvn dependency:tree $ mvn 依赖项:树

    [INFO] Scanning for projects... enter code here [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building {Project Name} [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ spring-mvc-logback --- [INFO] com.sj.common:spring-mvc-logback:war:1.0-SNAPSHOT [INFO] +- org.springframework:spring-core:jar:4.1.6.RELEASE:compile [INFO] +- org.springframework:spring-webmvc:jar:4.1.6.RELEASE:compile [INFO] | +- org.springframework:spring-beans:jar:4.1.6.RELEASE:compile [INFO] | +- org.springframework:spring-context:jar:4.1.6.RELEASE:compile [INFO] | | \\- org.springframework:spring-aop:jar:4.1.6.RELEASE:compile [INFO] | | \\- aopalliance:aopalliance:jar:1.0:compile [INFO] | +- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile [INFO] | \\- org.springframework:spring-web:jar:4.1.6.RELEASE:compile [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile [INFO] | \\- org.slf4j:slf4j-api:jar:1.7.12:compile [INFO] +- ch.qos.logback:logback-classic:jar:1.1.3:compile [INFO] | \\- ch.qos.logback:logback-core:jar:1.1.3:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.937 s [INFO] Finished at: 2015-06-19T19:17:54+08:00 [INFO] Final Memory: 13M/308M [INFO] ------------------------------------------------------------------------

And you will be able to watch all the dependencies and versions associated with that dependency.您将能够查看与该依赖项关联的所有依赖项和版本。

In Eclipse IDE:在 Eclipse IDE 中:

  1. Open your pom.xml打开你的 pom.xml
  2. Go to "Effective POM" tab转到“有效 POM”选项卡
  3. Search for "tomcat"搜索“tomcat”
  4. Find <tomcat.version> line, for example: <tomcat.version>9.0.27</tomcat.version>找到<tomcat.version>行,例如: <tomcat.version>9.0.27</tomcat.version>

For those who use PCF ie cloudfoundry对于那些使用 PCF 的人,即 cloudfoundry

I generally keep spring boot tomcat dependency as provided Which means my local tomcat version may be slightly different.我通常保留 spring boot tomcat 依赖项,这意味着我本地的 tomcat 版本可能略有不同。

The java buildpack includes the tomcat version java buildpack 包含 tomcat 版本

https://github.com/cloudfoundry/java-buildpack/releases https://github.com/cloudfoundry/java-buildpack/releases

eg java buildpack 4.19.1 comes with Openjdk 1.8.0_212 and tomcat 9.0.19例如,java buildpack 4.19.1 带有 Openjdk 1.8.0_212 和 tomcat 9.0.19

Consider the below snippet of your project's pom.xml wherein default parent is spring-boot-starter-parent考虑您项目的pom.xml的以下片段,其中默认父级是spring-boot-starter-parent

Your project pom.xml你的项目 pom.xml

<!--Spring boot parent project -->
<parent>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-parent</artifactId>
 <version>2.4.5</version>
 <relativePath /> <!-- lookup parent from repository -->
</parent>

Next lookup pom.xml of spring-boot-starter-parent project to see the dependencies, it has the spring-boot-dependencies as its parent.接下来查找spring-boot-starter-parent项目的pom.xml以查看依赖项,它以spring-boot-dependencies作为其父项。 If using modern IDEs like IntelliJ/Vscode can easily traverse within IDE.如果使用像 IntelliJ/Vscode 这样的现代 IDE 可以轻松地在 IDE 中遍历。

spring-boot-starter-parent pom.xml spring-boot-starter-parent pom.xml

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-dependencies</artifactId>
  <version>2.4.5</version>
</parent>

One level up again ie, to spring-boot-dependencies it further doesn't have a parent, under properties all the defaults are listed.再上一层,即对于spring-boot-dependencies它进一步没有父级,在属性下列出了所有默认值。 Sample snippet below having non exhaustive list showing only tomcat.下面的示例片段具有仅显示 tomcat 的非详尽列表。

spring-boot-dependencies pom.xml spring-boot-dependencies pom.xml

<properties>
  <!-- Other dependencies -->
  <tomcat.version>9.0.45</tomcat.version>
  <!-- Other dependencies -->
</properties>

This way, we can search for all the defaults out of the box.这样,我们可以立即搜索所有默认值。

通过控制台打印依赖树

mvn dependency:tree

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM