code: private static void watchFile(final File file, ResourceLoader resourceLoader, String resourcePaths) {
          LOGGER.info("监控文件："+file.toString());
          DirectoryWatcher.WatcherCallback watcherCallback = new DirectoryWatcher.WatcherCallback(){
              private long lastExecute = System.currentTimeMillis();
              @Override
              public void execute(WatchEvent.Kind<?> kind, String path) {
                  if(System.currentTimeMillis() - lastExecute > 1000){
                      lastExecute = System.currentTimeMillis();
                      if(!path.equals(file.toString())){
                          return;
                      }
                      LOGGER.info("事件："+kind.name()+" ,路径："+path);
                      synchronized(AutoDetector.class){
                          DirectoryWatcher dw = WATCHER_CALLBACKS.get(this);
                          String paths = RESOURCES.get(dw);
                          ResourceLoader loader = RESOURCE_LOADERS.get(dw);
                          LOGGER.info("重新加载数据");
                          loadAndWatch(loader, paths);
                      }
                  }
              }
  
          };
          DirectoryWatcher fileWatcher = DirectoryWatcher.getDirectoryWatcher(watcherCallback,
                  StandardWatchEventKinds.ENTRY_MODIFY,
                      StandardWatchEventKinds.ENTRY_DELETE);
          fileWatcher.watchDirectory(file.getParent());
          WATCHER_CALLBACKS.put(watcherCallback, fileWatcher);
          RESOURCES.put(fileWatcher, resourcePaths);
          RESOURCE_LOADERS.put(fileWatcher, resourceLoader);
      }
docs: 监控文件变化
  @param file 文件