Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swag

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.2.12.RELEASE.jar:2.2.12.RELEASE]
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:184) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
    at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[spring-boot-2.2.12.RELEASE.jar:2.2.12.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.12.RELEASE.jar:2.2.12.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) [spring-boot-2.2.12.RELEASE.jar:2.2.12.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.12.RELEASE.jar:2.2.12.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.12.RELEASE.jar:2.2.12.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.12.RELEASE.jar:2.2.12.RELEASE]
    at com.lxyk.yygh.ServiceGatewayApplication.main(ServiceGatewayApplication.java:11) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
 

报错代码如上:

微服务架构

Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swag_第1张图片

 

gateway和swagger冲突:

注意:我这里service-gateway并没有使用swagger,而是使用工具类工程导入时带入

如果想看gateway整合swagger,可跳过文章

。。之前本来没有报错,隔天启动就报错。。。一天多了才解决,各种方案均试过,然后又会出各种报错,bug制造机

gateway和以下的包都冲突:

所以如果导入了web的jar包,需要注释掉

gateway使用的是webflux,和web会造成冲突

           
          org.springframework.boot
            spring-boot-starter-web
          provided
        

网关和@EnableSwagger2会冲突,如果你去掉这个注解就不会报错,但是,会导致其他模块引入的swagger测试失效:

Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swag_第2张图片 

 解决方案:

查看网关的maven依赖树

,查找swagger出现的依赖工程 ,我这里已经去掉了该工程

Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swag_第3张图片

 

去掉有swagger依赖的工程,但是不明白为什么之前没报错,突然就报错了,跟着视频里面的老师写的,是这样写的也没报错 

明明主启动类没有使用@ComponentScan来扫描swagger的包,但是swagger却生效

待研究,,

Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swag_第4张图片 

Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swag_第5张图片 

 

 

你可能感兴趣的:(头疼报错的日常,java,开发语言)