springboot 注解@Value 注入配置文件值报错
springboot 注解@Value 注入配置文件值报错:Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'myconfig.webpath' in value "${myconfig.webpath}"
application.yml:
myconfig:
webpath: "http://10.121.0.33"
jgsj: "0 0 * * * ?"
XXService :
@Value("${myconfig.webpath}")
private String webpath;
Error creating bean with name 'compent': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileDownloadService': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'myconfig.webpath' in value "${myconfig.webpath}"
我尝试解决方案:
1、检查拼写错误:通过复制查找方式,没有拼写错误
2、注释配置文件中其他的配置,因为之前简单的项目写个这个注解,不认为是配置文件的问题。
3、在Application里面加入注解@PropertySource(value="classpath:application.yml"):没有效果