bug:Could not resolve placeholder ‘xxx‘ in value “${xxx}
程序员文章站
2022-04-28 16:36:58
...
问题背景及内容
背景
学习微服务过程中,第一次接触.yml文件,在学习读取application.yml文件属性值的时候遇到该错误。
application.yml文件:
my:
name:forzep
age:12
myController.java文件:
@Value("${my.name}")
private String name;
报错内容
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'miyaController':
Injection of autowired dependencies failed;
nested exception is java.lang.IllegalArgumentException:
Could not resolve placeholder 'my.name' in value "${my.name}"
原因及解决
原因
.yml文键对格式要求极为严谨,在属性与值之间不能缺少空格。
解决
加上空格就ok
my:
name: forzep
age: 12
拓展
.yml文件动态定位:
被调用文件命名:application-{profile}.yml
调用文件内容:
spring:
profiles:
active: dev <!-- {profile} -->
上一篇: PHP判断字符类型 PHP 判断值为整数
下一篇: 报错:Could not find a declaration file for module 'xxx'. 'xxx' implicitly has an 'any' type.
推荐阅读
-
【Bug解决】org.apache.ibatis.type.TypeException: The alias ‘xxxx‘ is already mapped to the value ‘xxx‘
-
java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in value
-
spring boot 提示 could not resolve placeholder in string value
-
【微服务】Springboot和ActiveMQ整合出现 Could not resolve placeholder 'xxx' in value "${xxx}"
-
spring cloud config 配置管理出现 Could not resolve placeholder 'hello' in value "${hello}"
-
spring cloud远程配置 Could not resolve placeholder 'gname' in value "${gname}"
-
bug:Could not resolve placeholder ‘xxx‘ in value “${xxx}
-
【Bug解决】org.apache.ibatis.type.TypeException: The alias ‘xxxx‘ is already mapped to the value ‘xxx‘
-
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'XXX'
-
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘xxx‘.