啟動springboot時報錯 APPLICATION FAILED TO START 包沖突
problem
具體日志如下
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:823)
The following method did not exist:
com.fasterxml.jackson.databind.Module.getTypeId()Ljava/lang/Object;
The calling method's class, org.springframework.http.converter.json.Jackson2ObjectMapperBuilder, was loaded from the following location:
jar:file:/Users/dream/.m2/repository/org/springframework/spring-web/5.3.13/spring-web-5.3.13.jar!/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.class
The called method's class, com.fasterxml.jackson.databind.Module, is available from the following locations:
jar:file:/Users/dream/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.3.3/jackson-databind-2.3.3.jar!/com/fasterxml/jackson/databind/Module.class
The called method's class hierarchy was loaded from the following locations:
com.fasterxml.jackson.databind.Module: file:/Users/dream/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.3.3/jackson-databind-2.3.3.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.http.converter.json.Jackson2ObjectMapperBuilder and com.fasterxml.jackson.databind.Module
Process finished with exit code 1
reason
報錯日志的意思
- com.fasterxml.jackson.databind.Module.getTypeId 這個方法不存在
- 此方法對應(yīng)的一個類 json.Jackson2ObjectMapperBuilder 來自 spring-web-5.3.13.jar 包
- 此方法對應(yīng)的另一個類 jackson.databind.Module 來自 jackson-databind-2.3.3.jar
觀察maven依賴
- 正常項目的依賴是 spring-web-5.3.13.jar 和 jackson-databind-2.13.0.jar
- 異常項目的依賴是 spring-web-5.3.13.jar 和 jackson-databind-2.3.3.jar
- 可以看到是 第二個包的版本低了,導(dǎo)致出現(xiàn)了包沖突
對比pom文件
- 對比正常和異常項目,發(fā)現(xiàn)正常項目 springboot 依賴是來自parent節(jié)點
- 異常項目 springboot 依賴是pom中 自定義
solution
采用parent方式引入springboot可以解決問題文章來源:http://www.zghlxwxcb.cn/news/detail-774989.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-774989.html
到了這里,關(guān)于啟動springboot時報錯 APPLICATION FAILED TO START 包沖突的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!