java.lang.NoClassDefFoundError 異常解決方法

org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'docket' defined in class path resource [com/XXX/XXX/config/SwaggerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.web.plugins.Docket]: Factory method 'docket' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/http/MediaType

今天在想項目裏添加swagger的時候,發現跑不起來,bean組件一直失敗,提示java.lang.NoClassDefFoundError: org/springframework/http/MediaType

後來一看傻眼了,忘記加spring-boot-starter-web,怪不得跑不起來。


異常:java.lang.NoClassDefFoundError: org/springframework/XXX/XXX
解決:找到對應的包,導入maven依賴就可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章