FileChangedReloadingStrategy跟新配置文件后无效问题原因

在Linux环境中,使用FileChangedReloadingStrategy进行配置文件动态加载时,有时更新文件后不生效。问题在于mv命令不会更新文件的最后修改时间,导致策略无法检测到变化。而cp命令会更新时间戳,因此建议使用cp命令确保配置文件的重新加载。
摘要由CSDN通过智能技术生成
问题描述

代码部署在Linux服务器上,因为需要长期修改或者添加数据,使用commons-configuration-1.10.jar
org.apache.commons.configuration.reloading.FileChangedReloadingStrategy来实现动态加载配置文件,避免重复的重启服务器,但有时会出现跟新配置文件以后,跟新的数据没有生效,重启服务器后配置文件生效。

问题原因

FileChangedReloadingStrategy()方法的描述:

/**
 * <p>A reloading strategy that will reload the configuration every time its
 * underlying file is changed.</p>
 * <p>This reloading strategy does not actively monitor a configuration file,
 * but is triggered by its associated configuration whenever properties are
 * accessed. It then checks the configuration file's last modification date
 * and causes a reload if this has changed.</p>
 * <p>To avoid permanent disc access on successive property lookups a refresh
 * delay can be specified. This has the effect that the configuration file's
 * last modification date is only chec
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值