spring boot在实体类中引用yml中的配置
@Value("${shiro.session.expireTime}")
private final int expireTime = 30;
一启动项目,就报错,提示could not resolve placeholder in string value,该错误基本上就是【找不到配置文件引起的(application.yml)】
2.解决方法
检查下target/classes目录下是否存在application.yml配置文件
如果存在,可在配置类上添加PropertySource主键根据错误日志判断是否存在application.yml配置文件。
@Configuration
@PropertySource("classpath:application.yml")
public class ShiroConfig {
报错信息:
java
.lang.IllegalArgumentException: Could not
resolve
placeholder
'hadoop.conf.dir' in
value
"${hadoop.conf.dir}"
问题排查:
1、首先排查代码中@
Value
注解和配置文件application.properties中的是否一致:
@
Value
("${hadoop.conf.dir}")
private
String
hadoop_conf_dir;
@
Value
("${spark
或者使用@ConfigurationProperties(prefix="xx")的到的值是空的。这个配置后面,把配置移到该配置前面即可。在获取配置文件的配置时报错。问题出在把配置信息放到了。
2.选中Idea右侧Profiles,然后Reload All Maven Projects。3.选中Idea右侧项目(root),然后Reload All Maven Projects。1.检测
spring
.profiles.active确实没有弄错。2.查看编译后的jar里的配置文件,也确实有xxx,但就是。1.选中最顶层项目,然后Rebuild Project。因为新增了一个profiles,没有主动清理并刷新。4.选中Idea右侧项目(root),然后clean。
一般来说报Could not
resolve
placeholder
'xxx' in
string
value
"${xxx}" 错误的原因都是由于项目中有多个地方的xml文件中用到了
<context:property-
placeholder
location="classpath:xxx.properties"/>
<bean id="propertyCon...
Android Studio更新3.6.3之后出现Could not
resolve
all artifacts for configuration ‘:classpath’.问题你是否和我一样,只因在人群中多看了他一眼?![在这里插入图片描述](https://img-blog.csdnimg.cn/20200507121220467.png)再也没能摆脱**的问题看了很多方法,下载证书,换国产镜像,改本机Host都没能解决。那么问题来了,有这么简单的方法要这篇文章干嘛。这篇文章为了解决每次创建新项目时都要手动修改配置的麻烦,提供解决方法。
你是否和我一样,只因在人群中多看了他一眼?
org.
spring
framework.beans.factory.BeanCreationException:
Error creating bean with name '
shiro
CasConfig':
Injection of autowired dependencies failed;
nested exception is ja...
这个其实也算是个小问题,就是拿来记录一下。
原文地址:https://blog.csdn.net/u012198209/article/details/88965922
一般来说报Could not
resolve
placeholder
‘xxx’ in
string
value
“${xxx}” 错误的原因都是由于项目中有多个地方的xml文件中用到了
<context:property-
placeholder
location=“classpath:xxx.properties”/>
今天用idea启动
spring
boot
的时候发现某个配置没找到
报错: Injection of autowired dependencies failed; nested exception is
java
.lang.IllegalArgumentException: Could not
resolve
placeho...