一、该问题的重现步骤是什么?
1. nacos配置了自定义数据,AuthFilter中使用@value获取
二、你期待的结果是什么?实际看到的又是什么?
希望可以正常启动并且获取值
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
四、请提供详细的错误堆栈信息,这很重要。
2024-07-04T09:58:30.509+08:00 WARN 20956 --- [blade-gateway] [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilter' defined in file [D:\文件\xxx\xxx\xxx\blade-gateway\target\classes\org\springblade\gateway\filter\AuthFilter.class]: Unsatisfied dependency expressed through constructor parameter 4: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2024-07-04T09:58:30.540+08:00 INFO 20956 --- [blade-gateway] [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-07-04T09:58:30.574+08:00 ERROR 20956 --- [blade-gateway] [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 4 of constructor in org.springblade.gateway.filter.AuthFilter required a bean of type 'java.lang.String' that could not be found.
Action:
Consider defining a bean of type 'java.lang.String' in your configuration.
五、若有更多详细信息,请在下面提供。
@AllArgsConstructor不要和@Autowried同时用
删掉@Autowried,@AllArgsConstructor改成@RequiredArgsConstructor
需要注入的类用final标记,其他的不加final。具体参考:https://center.javablade.com/blade/BladeX-Biz/src/branch/master/blade-service/blade-demo/src/main/java/com/example/demo/controller/DemoController.java
参考这个类获取配置:
扫一扫访问 Blade技术社区 移动端