美文网首页
org.apache.tomcat.util.modeler.R

org.apache.tomcat.util.modeler.R

作者: dozenx | 来源:发表于2022-12-07 16:27 被阅读0次

    今天为了修复jackson漏洞 要升级spring 版本,可是升级了之后报错

    An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:177)
    

    The following method did not exist:

    org.apache.tomcat.util.modeler.Registry.disableRegistry()V
    

    The method's class, org.apache.tomcat.util.modeler.Registry, is available from the following locations:

    jar:file:/C:/Users/%e7%8e%8b%e8%b6%85%e5%87%a1/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.63/tomcat-embed-core-8.5.63.jar!/org/apache/tomcat/util/modeler/Registry.class
    

    The class hierarchy was loaded from the following locations:

    org.apache.tomcat.util.modeler.Registry: file:/C:/Users/%e7%8e%8b%e8%b6%85%e5%87%a1/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.63/tomcat-embed-core-8.5.63.jar
    

    进入 TomcatServletWebServerFactory.java:177 查看
    @Override
    public WebServer getWebServer(ServletContextInitializer... initializers) {
    if (this.disableMBeanRegistry) {
    Registry.disableRegistry();
    }
    disableRegistry是红的说明没这个方法

    显示的jar包是 org.springframework.boot:spring-boot:2.3.5.RELEASE

    那tomcat 的版本应该是spring boot parent里指定的啊 ,为什么

    spring boot 内嵌的tomcat 版本查看

    http://t.zoukankan.com/EasonWu-p-10788757.html

    我直接在 pom.xml里 用maven helper dependency Analyzer 查看tomcat版本

    image.png

    f12点进去 查看 spring-boot-starter-web-20.3.5.RELEASE.pom文件

    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <version>2.3.5.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    

    而tomcat 2.3.5 的版本

    <dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-core</artifactId>
    <version>9.0.39</version>
    <scope>compile</scope>
    <exclusions>
    <exclusion>
    <artifactId>tomcat-annotations-api</artifactId>
    <groupId>org.apache.tomcat</groupId>
    </exclusion>
    </exclusions>

    是9.0.39版本啊

    根据错误日志
    The method's class, org.apache.tomcat.util.modeler.Registry, is available from the following locations:

    jar:file:/C:/Users/%e7%8e%8b%e8%b6%85%e5%87%a1/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.63/tomcat-embed-core-8.5.63.jar!/org/apache/tomcat/util/modeler/Registry.class
    

    The class hierarchy was loaded from the following locations:

    org.apache.tomcat.util.modeler.Registry: file:/C:/Users/%e7%8e%8b%e8%b6%85%e5%87%a1/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.63/tomcat-embed-core-8.5.63.jar
    

    进入目录查看C:\Users\王超凡.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.39
    是有9.0.39版本的

    也就是说这个maven 错乱了?

    在工程里强制指定tomcat 版本

    <dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-core</artifactId>
    <version>9.0.39</version>
    <scope>compile</scope>
    <exclusions>
    <exclusion>
    <artifactId>tomcat-annotations-api</artifactId>
    <groupId>org.apache.tomcat</groupId>
    </exclusion>
    </exclusions>
    </dependency>

    终于能启动正常了

    相关文章

      网友评论

          本文标题:org.apache.tomcat.util.modeler.R

          本文链接:https://www.haomeiwen.com/subject/phwnfdtx.html