程序突然报@Value获取不到值的坑

昨天程序还好好的,然后今天死活起不来,部分报错如下

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-24 09:27:17,268 [restartedMain] ERROR [org.springframework.boot.SpringApplication] SpringApplication.java:826 - Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtAuthenticationTokenFilter': Unsatisfied dependency expressed through field 'tokenService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenService': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'token.header' in value "${token.header}"

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'token.header' in value "${token.header}"

 

我就先看看是不是有人提交了代码,我没更新,一看也没人提交

我就再看是不是我手抖,少了或者多了什么,更git上的版本进行对比,也没什么区别,但是在同时电脑能跑起来,我电脑就不行,我就纳闷了

然后检查yml文件也有相关的配置、使用的时候也是通过@Autowired注入,也用了@Component注解,但是还是无法获取到配置文件的值【之前进行代码对比,就没发现问题】

重启,重新build都不管用

然后一想,会不会是跟jdk的版本有关,然后我就切换jdk版本,也没用,切换启动设置里面的JRE,也是不行

程序突然报@Value获取不到值的坑_第1张图片

最后实在没招了

maven重新reimport, WTF,项目跑起来了

你可能感兴趣的:(spring,boot,java,spring,后端)