v2.8.0 版本prod环境报knife4j找不到class

Blade 未结 3 3489
421048337
421048337 剑圣 2021-04-14 14:55

一、该问题的重现步骤是什么?

1.v2.8.0 版本jar包运行 --spring.profiles.active=prod时,dev环境没有问题

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

v2.8.0 版本

四、请提供详细的错误堆栈信息,这很重要。

INFO: Sentinel log output type is: file

INFO: Sentinel log charset is: utf-8

INFO: Sentinel log base directory is: /root/logs/csp/

INFO: Sentinel log name use pid is: false

2021-04-14 14:50:21.389  INFO 738 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration' of type [com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2021-04-14 14:50:21.917  WARN 738 --- [           main] io.undertow.websockets.jsr               : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used

2021-04-14 14:50:21.965  INFO 738 --- [           main] io.undertow.servlet                      : Initializing Spring embedded WebApplicationContext

2021-04-14 14:50:21.966  INFO 738 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 5081 ms

2021-04-14 14:50:22.308  WARN 738 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.

2021-04-14 14:50:22.308  INFO 738 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.

2021-04-14 14:50:22.331  INFO 738 --- [           main] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@1fc0053e

2021-04-14 14:50:22.613  INFO 738 --- [           main] o.s.b.a.e.web.ServletEndpointRegistrar   : Registered '/actuator/hystrix.stream' to hystrix.stream-actuator-endpoint

2021-04-14 14:50:22.938  INFO 738 --- [           main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource

2021-04-14 14:50:24.048  INFO 738 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited

2021-04-14 14:50:28.393  WARN 738 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dynamicResponseModelReader' defined in URL [jar:file:/services/blade/jar/blade-system.jar!/BOOT-INF/lib/knife4j-spring-2.0.8.jar!/com/github/xiaoymin/knife4j/spring/plugin/DynamicResponseModelReader.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'springfox.documentation.schema.TypeNameExtractor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

2021-04-14 14:50:28.400  INFO 738 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closing ...

2021-04-14 14:50:28.410  INFO 738 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed

2021-04-14 14:50:28.437  INFO 738 --- [           main] ConditionEvaluationReportLoggingListener : 


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-04-14 14:50:29.106 ERROR 738 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************

APPLICATION FAILED TO START

***************************


Description:


Parameter 0 of constructor in com.github.xiaoymin.knife4j.spring.plugin.DynamicResponseModelReader required a bean of type 'springfox.documentation.schema.TypeNameExtractor' that could not be found.



Action:


Consider defining a bean of type 'springfox.documentation.schema.TypeNameExtractor' in your configuration.

五、若有更多详细信息,请在下面提供。

3条回答
  • 检查下nacos上面的配置

    P[G5_A4`C3JM7NQJ}LOD6[B.png

    0 讨论(0)
  • 2021-04-14 15:22

    配置都是一样的image.pngimage.png

    0 讨论(0)
  • 2021-04-14 16:40

    我跑了prod环境没有问题啊,你有没有改动过其他地方。

    另外为了尽可能排除其他因素,你把dev的配置复制到prod的配置,让两种环境的配置一样。然后启动的时候再指定prod的环境,如果和dev配置都一样,prod还是报错,那肯定就是底层的原因。要去排查一下是否有改动影响了。

    image.png


    BladeX关于knife4j的处理就只有以下两个类

    image.png

    image.png

    作者追问:2021-04-14 17:09

    问题已解决,看到开发手册说使用注解可以限制生产环境,添加了这个@Profile({"dev","test"}),去掉了就可以启动

    image.png


    0 讨论(0)
提交回复