Spring中@Value注解的注意事项
通过
@Value
注解将application.yml
中的值映射到一个Spring管理的Bean的字段上。
@Value只能注入普通变量
1 | //队列的名称(自动注入) |
以上代码会导致SpringBoot启动时报错:Could not resolve placeholder ‘XXX.XXX‘ in value
解决
- 删除
public
关键字
- 删除
引用链接
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 HumgTop's Blog!
评论