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依赖就可。