简体   繁体   English

在 spring 引导上更改嵌入式 tomcat 版本

[英]Change embedded tomcat version on spring boot

I want to downgrade my embedded tomcat from 8.5.6 to 8.5.51.我想将我的嵌入式 tomcat 从 8.5.6 降级到 8.5.51。

In my logs, I can find the information below:在我的日志中,我可以找到以下信息:

"spring-boot-starter-tomcat/1.4.3.RELEASE/spring-boot-starter-tomcat-1.4.3.RELEASE.jar" ".m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.6/tomcat-embed-core-8.5.6.jar" “spring-boot-starter-tomcat/1.4.3.RELEASE/spring-boot-starter-tomcat-1.4.3.RELEASE.jar” “.m2/repository/org/apache/tomcat/embed/tomcat-embed-core /8.5.6/tomcat-embed-core-8.5.6.jar"

But in my pom.xml files, I do not have any references to tomcat.但是在我的 pom.xml 文件中,我没有对 tomcat 的任何引用。

Doing a grep command, there is no return to 'spring-boot-starter-parent' or 'spring-boot-starter-tomcat'.执行 grep 命令,没有返回到“spring-boot-starter-parent”或“spring-boot-starter-tomcat”。

Where and how can I explicitly add the tomcat version I want?我可以在哪里以及如何明确添加我想要的 tomcat 版本?

if your project or one of your dependencies needs to override the version of a transitive dependency that is managed by the parent POM, just add a version property for that dependency.如果您的项目或您的一个依赖项需要覆盖由父 POM 管理的传递依赖项的版本,只需为该依赖项添加一个版本属性。 For this rule to work the parent POM has to define version properties for all the dependencies that it manages (the spring-boot-starter-parent does this).为了让这个规则起作用,父 POM 必须为其管理的所有依赖项定义版本属性(spring-boot-starter-parent 会这样做)。

<properties>
        <tomcat.version>8.5.51</tomcat.version>
</properties>

You can check where that dependency is coming from by looking at the dependency tree:您可以通过查看依赖关系树来检查该依赖关系的来源:

mvn dependency:tree -Dverbose 

More info here . 更多信息在这里

Another option is to explicitly set the version in your pom.xml file or exclude it from the dependency that is including it:另一种选择是在pom.xml文件中显式设置版本或将其从包含它的依赖项中排除:

<dependency>
  <groupId>a.group</groupId>
  <artifactId>a.artifact</artifactId>
  <version>a.version</version>
  <exclusions>
    <exclusion>
      <artifactId>tomcat</artifactId>
      <groupId>tomcat-group</groupId>
    </exclusion>
  </exclusions>
<dependency>

More info here .更多信息在这里

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

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