Nacos统一配置管理报错BeanCreationException

博客记录了Spring项目中出现的org.springframework.beans.factory.BeanCreationException报错,具体为无法解析'pattern.dateformat'占位符。给出了几种解决方案,如修改@Value注解参数、使用@NacosValue等,还补充了Spring3对bootstrap.xml无优先需引入依赖的情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错:org.springframework.beans.factory.BeanCreationException: Error creating bean wIth name 'userController': Injection of autowired dependencies failed; nested exception is java.lang.llegaLArgumentexceptton: Could not resolve placeholder 'pattern.dateformat in value "${pattern.dateformat}"

Spring: 2.3.9

Nacos: 1.4.1

idea: 2023.3.4

查到好几种解决方案:

方案一:@Value("${pattern.dateformat}")改为@Value("${logging.pattern.dateformat}") ,对我有效

方案二:@Value改为@NacosValue,尝试之后问题变成空指针异常,在Controller类加上@RefreshScope,依旧报错

方案三:@Value("${pattern.dateformat}")改为@Value("${pattern:dateformat}"),无效

补充:

Spring3对bootstrap.xml没有优先,需要引入依赖(不确定,没尝试过)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值