fix Setting autoload

This commit is contained in:
Looly 2025-04-17 16:16:27 +08:00
parent d58d5ea032
commit 33aa3ecf3a
2 changed files with 11 additions and 7 deletions

View File

@ -79,12 +79,12 @@
Hutool目前主要版本4.x、5.x、6.x、7.x选择如下
| 版本 | jdk | Maven仓库 | 主要特点 |
|-----|--------|-----------------------------------------------------------------------------------------------------|-------------------------------------|
| 4.x | jdk1.7 | [cn.hutool/hutool-all/4.x](https://mvnrepository.com/artifact/cn.hutool/hutool-all/4.6.17) | jdk1.7编译 |
| 5.x | jdk1.8 | [cn.hutool/hutool-all/5.x ](https://mvnrepository.com/artifact/cn.hutool/hutool-all) | jdk1.8编译,使用JavaEE,适配JDK11、17、21 |
| 版本 | jdk | Maven仓库 | 主要特点 |
|-----|--------|--------------------------------------------------------------------------------------------------------|-------------------------------------|
| 4.x | jdk1.7 | [cn.hutool/hutool-all/4.x](https://mvnrepository.com/artifact/cn.hutool/hutool-all/4.6.17) | jdk1.7编译 |
| 5.x | jdk1.8 | [cn.hutool/hutool-all/5.x ](https://mvnrepository.com/artifact/cn.hutool/hutool-all) | jdk1.8编译,使用JavaEE,适配JDK11、17、21 |
| 6.x | jdk1.8 | [org.dromara.hutool/hutool-all/6.x ](https://mvnrepository.com/artifact/org.dromara.hutool/hutool-all) | jdk1.8编译,使用Jakarta EE,适配JDK11、17、21 |
| 7.x | jdk17 | [cn.hutool/hutool-all/6.x ](https://mvnrepository.com/artifact/org.dromara.hutool/hutool-all) | jdk17编译,使用Jakarta EE,适配17+ |
| 7.x | jdk17 | [cn.hutool.v7/hutool-all/6.x ](https://mvnrepository.com/artifact/org.dromara.hutool/hutool-all) | jdk17编译,使用Jakarta EE,适配17+ |
## 🛠️包含组件

View File

@ -26,6 +26,7 @@ import cn.hutool.v7.core.io.resource.Resource;
import cn.hutool.v7.core.io.resource.ResourceUtil;
import cn.hutool.v7.core.io.watch.WatchMonitor;
import cn.hutool.v7.core.io.watch.WatchUtil;
import cn.hutool.v7.core.io.watch.watchers.DelayWatcher;
import cn.hutool.v7.core.io.watch.watchers.SimpleWatcher;
import cn.hutool.v7.core.lang.Assert;
import cn.hutool.v7.core.text.CharUtil;
@ -35,6 +36,7 @@ import cn.hutool.v7.log.LogUtil;
import cn.hutool.v7.setting.props.Props;
import java.io.File;
import java.io.Serial;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.WatchEvent;
@ -56,6 +58,7 @@ import java.util.function.Consumer;
* @author Looly
*/
public class Setting extends AbsSetting implements Map<String, String> {
@Serial
private static final long serialVersionUID = 3618305164959883393L;
/**
@ -199,7 +202,8 @@ public class Setting extends AbsSetting implements Map<String, String> {
Assert.notNull(this.resource, "Setting resource must be not null !");
// 先关闭之前的监听
IoUtil.closeQuietly(this.watchMonitor);
this.watchMonitor = WatchUtil.ofModify(resource.getUrl(), new SimpleWatcher() {
this.watchMonitor = WatchUtil.ofModify(resource.getUrl(), new DelayWatcher(new SimpleWatcher() {
@Serial
private static final long serialVersionUID = 5190107321461226190L;
@Override
@ -210,7 +214,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
callback.accept(Setting.this);
}
}
});
}, 600));
this.watchMonitor.start();
LogUtil.debug("Auto load for [{}] listenning...", this.resource.getUrl());
}