关于disconf不支持Spring5和SpringBoot2.0的问题解决

修复Spring 5兼容性问题
本文介绍了一项针对disconf项目的源码修改,解决了在Spring 5环境下使用时出现的兼容性问题。通过更新PropertyPlaceholderConfigurer类中的方法实现,避免了使用已废弃的API,确保了配置属性能够正确加载。

由于作者已经不再维护这个项目,所以有问题只能自己改源码来修复了。

改动点:
com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer第97行:

// then, business as usual. no recursive reloading placeholders please.
return super.parseStringValue(buf.toString(), props, visitedPlaceholders);

改为:

// Fixed an issue with using obsolete api, which can't be started in spring5.
// then, business as usual. no recursive reloading placeholders please.PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders);
return helper.replacePlaceholders(strVal, props);

GitHub地址:https://github.com/cjbi/disconf

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值