Spring Boot提供的重启技术使用两个类加载器。一个基础的类加载器用来加载不更改的类(例如,来自第三方jar的类), 而我们开发的类用一个叫做重新启动的类加载器(RestartClassLoader)来加载。 每次更改代码后,触发类重新加载时,是将原来的RestartClassLoader抛弃,然后重新创建一个新的RestartClassLoader。这种方法意味着应用程序重新启动通常比“冷启动”快得多,因为基本类加载器已经可用并已填充。
/** * Patterns that should be excluded from triggering a full restart. */ private String exclude = DEFAULT_RESTART_EXCLUDES;
/** * Additional patterns that should be excluded from triggering a full restart. */ private String additionalExclude;
/** * Amount of time to wait between polling for classpath changes. */ private Duration pollInterval = Duration.ofSeconds(1);
/** * Amount of quiet time required without any classpath changes before a restart is * triggered. */ private Duration quietPeriod = Duration.ofMillis(400);
/** * Name of a specific file that, when changed, triggers the restart check. If not * specified, any classpath file change triggers the restart. */ private String triggerFile;
/** * Additional paths to watch for changes. */ private List<File> additionalPaths = new ArrayList<>();
/** * Whether to log the condition evaluation delta upon restart. */ privateboolean logConditionEvaluationDelta = true; }