我是靠谱客的博主 乐观马里奥,这篇文章主要介绍Springboot 2.x 无法读取yml配置值的问题:Could not resolve placeholder xxx value '${xxx}',现在分享给大家,希望可以做个参考。
最近在用Springboot2.1 新建demo工程的时候,在DataSourceConfig类中通过 @Value("${spring.datasource.url}") 的方式引用application.yml 中配置的参数时,提示:
Could not resolve placeholder xxx value ‘${xxx}’
本文是基于Springboot最新版本2.1.1来处理的,在pom文件中增加依赖即可:
复制代码
1
2
3
4
5<dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> </dependency>
然后引用方式如下(图中是debug断点状态,可以看到配置参数确实已经成功赋值了):
转载于:https://www.cnblogs.com/xiaocy66/p/10589246.html
最后
以上就是乐观马里奥最近收集整理的关于Springboot 2.x 无法读取yml配置值的问题:Could not resolve placeholder xxx value '${xxx}'的全部内容,更多相关Springboot内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复