org.apache.tomcat.util.modeler.Registry.disableRegistry 方法不存在

今天为了修复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文件



  org.springframework.boot
  spring-boot-starter-tomcat
  2.3.5.RELEASE
  compile

而tomcat 2.3.5 的版本


org.apache.tomcat.embed
tomcat-embed-core
9.0.39
compile


tomcat-annotations-api
org.apache.tomcat

是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 版本


org.apache.tomcat.embed
tomcat-embed-core
9.0.39
compile


tomcat-annotations-api
org.apache.tomcat


终于能启动正常了

你可能感兴趣的:(org.apache.tomcat.util.modeler.Registry.disableRegistry 方法不存在)