springboot报错无法读取配置文件:Could not resolve placeholder 'xxx' in value "${XXXX}

2023-11-15

在springboot项目中,通过@Value("${aliyun.oss.file.endpoint}")读取application.properties配置文件的内容报错:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'constantPropertiesUtils': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'aliyun.oss.file.filehost' in value "${aliyun.oss.file.filehost}"
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:403) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1429) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at com.rwh.oss.OssApplication.main(OssApplication.java:18) [classes/:na]
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'aliyun.oss.file.filehost' in value "${aliyun.oss.file.filehost}"
	at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:236) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:908) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1228) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:636) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:397) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	... 17 common frames omitted

解决办法

很简单,只需要在启动类加上

	@Bean
    public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {

        PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer();

        c.setIgnoreUnresolvablePlaceholders(true);

        return c;
    }

即可成功启动

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

springboot报错无法读取配置文件:Could not resolve placeholder 'xxx' in value "${XXXX} 的相关文章

随机推荐

  • nginx关键字

    对关键字的解释会慢慢加上 master进程 worker进程 pass proxy core Nginx c daemon master process timer resolution pid lock file worker proce
  • 如何正确使用示波器的温度延长线扩展功能

    电子产品的信号测试验证过程中 不可避免地 需要进行高低温工况下的信号完整性测试 但是 目前的高速有源探头的工作温度范围有限不足以直接使用 为此 诸如泰克 是德科技等仪器公司 都有相对应的测试解决方案 基本采用的是 焊接前端 温度延长线 有源
  • 图论17(Leetcode864.获取所有钥匙的最短路径)

    用二进制表示获得的钥匙 假设n 钥匙个数 000000000代表没有钥匙 0000000001代表有idx为1的钥匙 0000000011代表有idx 1 2的钥匙 这方法巧妙又复杂 代码 class Solution static int
  • 补码的求法

    补码 源码取反再加一 eg CAN通信的一部分 1024对应0xfcc 第一种方法 1024二进制 0000010000000000 注意数据类型 需要加上0 取反 1111101111111111 加一 1111110000000000
  • Base64编码相关知识总结

    Base64编码是什么 Base64 顾名思义 就是包括小写字母a z 大写字母A Z 数字0 9 符号 一共64个字符的字符集 另加一个 实际是65个字符 任何符号都可以转换成这个字符集中的字符 这个转换过程就叫做base64编码 Bas
  • jdbc的内容以及如何在5秒钟后自动跳转到login.html页面

    首先 在5秒钟之后跳转到login html 最初的解决方法 try Thread sleep 5000 response sendRedirect login html catch Exception e e printStackTrac
  • STM32 GPIO |CSDN创作打卡

    GPIO结构框图 推挽输出 0 3 3 在该结构中输入高电平时 上方的P MOS导通 下方的N MOS截止 对外输出高电平 而在该结构中输入低电平时 N MOS管导通 P MOS截止 对外输出低电平 当引脚高低电平切换时 两个管子轮流导通
  • 如何下载b站视频到本地

    传送门 转载于 https www cnblogs com yaoling1997 p 10793366 html
  • assert()理解

    源自一道CTF题 理解全部写在注释里面 if isset GET page page GET page else page home file templates page php I heard is dangerous strpos通过
  • JAVA中字符串长度和(字符串)数组长度的函数【string.length和string.length()】

    字符串数组strs 获取数组的长度是利用数组的属性length 所以就是 strs length 字符串strs 获取长度的话是调用strs length 方法 字符串长度 字符串数组长度 字符串数组的长度的 因为任意的数组都有length
  • 五十七.斐波那契数列JAVA

    public class Main public static int fibonacci int n if n 0 n 1 return n else return fibonacci n 1 fibonacci n 2 public s
  • 2021-07-01

    2021年已经过去七个月了 学习目标 把vue element echarts给撸下来 学习内容 7 1 7 4 学习 Echarts 7 5 7 11 学习封装router 7 12 7 18 学习如何部署网站到gitee 7 19 7
  • 对象池学习

    概念 为了避免大量创建 构造 对象 销毁 析构 对象带的性能开销 设计 对象队列 初始化时 指定队列长度 出队 入队操作需要加锁保护 对象的构造 在初始化对象池时构造好 对象并不是一开始全部构造好 而是在获取对象的过程中构造 构造之后便保存
  • Linux平台下安全编译

    1 操作系统的软件堆栈 内存映射等区域配置 mmap vdso页 共享库等 实现方式 修改操作系统文件 proc sys kernel randomize va space 内容改为2 原因 ASLR针对缓冲区溢出攻击 此处将堆栈 共享库映
  • jsp体质表_国家学生体质健康网数据上报平台:http://www.csh.edu.cn/MOETC/index.jsp

    国家学生体质健康网数据上报平台即 国家学生体质健康标准数据管理分析系统 数据上报流程 1 登录中国学生体质健康网 www csh edu cn 进行上报学校网上登记并下载验证文件 ebm 2 使用国家数据库上报软件进行数据上报 3 登录中国
  • Java面向对象(基础)

    面向对象内容的三条主线 Java类及类的成员 重点 属性 方法 构造器 熟悉 代码块 内部类 面向对象的特征 封装 继承 多态 抽象 其他关键字的使用 this super package import static final inter
  • springboot启动报错 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded 。。

    一 错误如下 二 错误的原因 项目启动是出现该错误的原因 SpringBoot SpringBootApplication该注释会有数据库的自动配置 但在项目配置文件中没有找到相关的配置导致的 三 解决方法 如果是配置错误修改配置就可以 如
  • 线上一次JVM FullGC搞得整晚都没睡,彻底崩溃~

    V xin ruyuanhadeng获得600 页原创精品文章汇总PDF 这篇文章给大家聊一次线上生产系统事故的解决经历 其背后代表的是线上生产系统的JVM FullGC可能引发的严重故障 一 业务场景介绍 先简单说说线上生产系统的一个背景
  • Mongodb使用

    一 注意事项 1 mongodb的32位版本仅支持存储2gb的数据 包括索引等所有数据 而64位则无限制 2 Mongodb使用内存映射数据 存储需要消耗大量的RAM 至少需要满足足够存储所有索引和热数据的物理内存 否则会大大影响性能 3
  • springboot报错无法读取配置文件:Could not resolve placeholder 'xxx' in value "${XXXX}

    在springboot项目中 通过 Value aliyun oss file endpoint 读取application properties配置文件的内容报错 org springframework beans factory Bea