spring-cloud 整合swagger2时启动报错没有发现controller的接口bean

在开发spring-boot+cloud 整合swagger2时,报错如下:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController': Unsatisfied dependency expressed through field 'testService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'easy.quick.cloud.user.TestService': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.BUILD-20180118.213124-42.jar:1.5.10.BUILD-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.BUILD-20180118.213124-42.jar:1.5.10.BUILD-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.BUILD-20180118.213124-42.jar:1.5.10.BUILD-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.BUILD-20180118.213124-42.jar:1.5.10.BUILD-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.BUILD-20180118.213124-42.jar:1.5.10.BUILD-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.BUILD-20180118.213124-42.jar:1.5.10.BUILD-SNAPSHOT]
	at easy.quick.web.EasyQuickWebApplication.main(EasyQuickWebApplication.java:11) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'easy.quick.cloud.user.TestService': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1316) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1282) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	... 19 common frames omitted
Caused by: java.lang.NullPointerException: null
	at springfox.documentation.schema.property.OptimizedModelPropertiesProvider.beanDescription(OptimizedModelPropertiesProvider.java:317) ~[springfox-schema-2.2.2.jar:2.2.2]
	at springfox.documentation.schema.property.OptimizedModelPropertiesProvider.propertiesFor(OptimizedModelPropertiesProvider.java:117) ~[springfox-schema-2.2.2.jar:2.2.2]
	at springfox.documentation.schema.property.OptimizedModelPropertiesProvider$$FastClassBySpringCGLIB$$cb306bb2.invoke() ~[springfox-schema-2.2.2.jar:2.2.2]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at springfox.documentation.spring.web.caching.CachingAspect.cachedValue(CachingAspect.java:86) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.caching.CachingAspect.operationsAndProperties(CachingAspect.java:69) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at springfox.documentation.schema.property.OptimizedModelPropertiesProvider$$EnhancerBySpringCGLIB$$7b759518.propertiesFor() ~[springfox-schema-2.2.2.jar:2.2.2]
	at springfox.documentation.schema.DefaultModelProvider.properties(DefaultModelProvider.java:151) ~[springfox-schema-2.2.2.jar:2.2.2]
	at springfox.documentation.schema.DefaultModelProvider.modelFor(DefaultModelProvider.java:85) ~[springfox-schema-2.2.2.jar:2.2.2]
	at springfox.documentation.schema.DefaultModelProvider$$FastClassBySpringCGLIB$$2c8f6146.invoke() ~[springfox-schema-2.2.2.jar:2.2.2]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at springfox.documentation.spring.web.caching.CachingAspect.cachedValue(CachingAspect.java:86) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.caching.CachingAspect.modelsAndDependencies(CachingAspect.java:80) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_152]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_152]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_152]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_152]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) ~[spring-aop-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at springfox.documentation.schema.DefaultModelProvider$$EnhancerBySpringCGLIB$$99fe9254.modelFor() ~[springfox-schema-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.scanners.ApiModelReader.read(ApiModelReader.java:66) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:91) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:62) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:101) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent(DocumentationPluginsBootstrapper.java:87) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent(DocumentationPluginsBootstrapper.java:50) ~[springfox-spring-web-2.2.2.jar:2.2.2]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:116) ~[spring-cloud-context-1.3.1.RELEASE.jar:1.3.1.RELEASE]
	at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:85) ~[spring-cloud-context-1.3.1.RELEASE.jar:1.3.1.RELEASE]
	at org.springframework.cloud.context.named.NamedContextFactory.getInstance(NamedContextFactory.java:121) ~[spring-cloud-context-1.3.1.RELEASE.jar:1.3.1.RELEASE]
	at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.get(FeignClientFactoryBean.java:193) ~[spring-cloud-netflix-core-1.4.2.RELEASE.jar:1.4.2.RELEASE]
	at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.feign(FeignClientFactoryBean.java:84) ~[spring-cloud-netflix-core-1.4.2.RELEASE.jar:1.4.2.RELEASE]
	at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:221) ~[spring-cloud-netflix-core-1.4.2.RELEASE.jar:1.4.2.RELEASE]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ~[spring-beans-4.3.14.BUILD-20180119.183552-15.jar:4.3.14.BUILD-SNAPSHOT]
	... 29 common frames omitted

 
  

 在网上查找各种资料,自己踩了多次坑发现,终于发现是swagger2的jar包版本与spring cloud起冲突,我这边用的是swagger2的jar包为2.2.2版本 
  

只需要把swagger2的版本在2.5.0上就没问题了

2.5.0


    io.springfox
    springfox-swagger2
    ${swagger2.version}


    io.springfox
    springfox-swagger-ui
    ${swagger2.version}

 
  

 
  


你可能感兴趣的:(spring,boot,spring,cloud)