报错解决java.lang.ClassCastException: class java.util.Collections$UnmodifiableMap cannot be cast to

错误代码:

java.lang.ClassCastException: class java.util.Collections$UnmodifiableMap cannot be cast to class java.util.LinkedHashMap (java.util.Collections$UnmodifiableMap and java.util.LinkedHashMap are in module java.base of loader 'bootstrap')
	at com.zhubayi.springbootbeanfactorypostprocessor.config.DecryptConfig.convertPropertySource(DecryptConfig.java:62) ~[classes/:na]
	at com.zhubayi.springbootbeanfactorypostprocessor.config.DecryptConfig.lambda$postProcessBeanFactory$1(DecryptConfig.java:50) ~[classes/:na]
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
	at com.zhubayi.springbootbeanfactorypostprocessor.config.DecryptConfig.postProcessBeanFactory(DecryptConfig.java:50) ~[classes/:na]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:358) ~[spring-context-6.0.6.jar:6.0.6]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:201) ~[spring-context-6.0.6.jar:6.0.6]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:747) ~[spring-context-6.0.6.jar:6.0.6]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:565) ~[spring-context-6.0.6.jar:6.0.6]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.4.jar:3.0.4]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-3.0.4.jar:3.0.4]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-3.0.4.jar:3.0.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[spring-boot-3.0.4.jar:3.0.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[spring-boot-3.0.4.jar:3.0.4]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[spring-boot-3.0.4.jar:3.0.4]
	at com.zhubayi.springbootbeanfactorypostprocessor.SpringBootBeanFactoryPostProcessorApplication.main(SpringBootBeanFactoryPostProcessorApplication.java:11) ~[classes/:na]

在这里插入图片描述
应为propertySource.getSource() 不能转为LinkedHashMap
解决办法

Map source=new LinkedHashMap<>();
source.putAll((Map) ps.getSource());

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值