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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35080907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 16:17:29  来源:igfitidea点击:

How to know which tomcat version embedded in spring boot

javamaventomcatspring-boot

提问by bNd

I used spring boot in project. It has inbuild tomcat server. I find out a jar spring-boot-starter-tomcat-1.2.5.RELEASE.jar. I required to do certain tomcat related configuration on linux server.

我在项目中使用了弹簧靴。它有内置的 tomcat 服务器。我找到了一个罐子spring-boot-starter-tomcat-1.2.5.RELEASE.jar。我需要在 linux 服务器上做一些与 tomcat 相关的配置。

How can I get to know which tomcat version used in this?

我怎样才能知道这里使用了哪个 tomcat 版本?

回答by Mateusz Sroka

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 Dependenciesand you can see that it uses Tomcat 8.0.23.

下面有部分Compile Dependencies,您可以看到它使用Tomcat 8.0.23.

回答by Sanghyun Lee

You can also check the version without leaving your IDEby 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 > ShowEffective POM 来查看有效的 pom 。

...or from the command line by issuing mvn help:effective-pom

...或从命令行发出 mvn help:effective-pom

回答by DaddyMoe

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

回答by Kalpesh Soni

For those who use PCF i.e. 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

e.g. 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

回答by Vijay Rajpurohit

You can check the versions of all the dependencies in the dependency tree.

您可以在依赖树中查看所有依赖的版本。

for that:

为了那个原因:

  • go to the directory of pom.xml
  • run the following command:

    $ mvn dependency:tree

    [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] ------------------------------------------------------------------------
    
  • 进入 pom.xml 目录
  • 运行以下命令:

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

您将能够查看与该依赖项关联的所有依赖项和版本。

回答by R2D2

In Eclipse IDE:

在 Eclipse IDE 中:

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

回答by Yosra ADDALI

Print the dependepency tree via the console with

通过控制台打印依赖树

mvn dependency:tree