今天為了修復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版本
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>
終于能啟動正常了