找到你要的答案

Q:Could not autowire SpringSwaggerConfig

Q:不能自动装配springswaggerconfig

I have created a spring MVC application with lots of restful services inside. For testing and keeping track of web services. I have integrated swagger in my project. But while running maven build I am getting below exception.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mangofactory.swagger.configuration.SpringSwaggerConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.servlet.ServletContext com.mangofactory.swagger.configuration.SpringSwaggerConfig.servletContext

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.servlet.ServletContext com.mangofactory.swagger.configuration.SpringSwaggerConfig.servletContext; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.servlet.ServletContext] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

What is the cause of this?

I have created a spring MVC application with lots of restful services inside. For testing and keeping track of web services. I have integrated swagger in my project. But while running maven build I am getting below exception.

致:org.springframework.beans.factory.beancreationexception:创建名为“COM豆错误。mangofactory。招摇。配置。springswaggerconfig”:对自动装配依赖注入失败;嵌套异常org.springframework.beans.factory.beancreationexception:不能自动装配领域:私人javax.servlet.servletcontext com.mangofactory.swagger.configuration.springswaggerconfig.servletcontext

致:org.springframework.beans.factory.beancreationexception:不能自动装配领域:私人javax.servlet.servletcontext com.mangofactory.swagger.configuration.springswaggerconfig.servletcontext;嵌套异常org.springframework.beans.factory.nosuchbeandefinitionexception:不合格豆型[ javax. servlet。ServletContext ]发现依赖:预计至少1豆的资格的候选人依赖自动装配。注释:{ @机构的依赖。springframework.豆。工厂。注释。自动绑定(需要= true)}

这是什么原因?

java  spring  maven  swagger  servlet-3.0