SpringBoot applies Automatic Restart and static resource livereload settings

SpringBoot applies Automatic Restart and static resource livereload settings
20.2 Automatic Restart
Applications that use spring-boot-devtools automatically restart whenever files on the classpath change. This can be a useful feature when working in an IDE, as it gives a very fast feedback loop for code changes. By default, any entry on the

classpath that points to a folder is monitored for changes. Note that certain resources, such as static assets and view templates, do not need to restart the application. , applications using spring-boot-devtools are automatically restarted. When working in the IDE, it provides a very fast feedback loop for code changes, which is a useful feature. By default, all entries under the path will be watched for changes. However, there are times when some resources, such as static assets and view templates, change without restarting the application.

20.2.1 Excluding Resources
Certain resources do not necessarily need to trigger a restart when they are changed. For example, Thymeleaf templates can be edited in-place. By default, changing resources in /META-INF/maven, /META-INF/resources, /resources, /static, /public, or /templates does not trigger a restart but does trigger a live reload. If you want to customize these exclusions, you can use the spring.devtools.restart.exclude property. For example, to exclude only /static and /public you would set the following property:

有些资源被更改时不需要触发服务重启。例如,Thymeleaf模板可以就地编辑而不触发服务重启。默认情况下,更改 /META-INF/maven, /META-INF/resources, /resources, /static, /public, or /templates 这些目录下的资源不会触发重启。也可以通过设置spring.devtools.restart.exclude属性来自定义这些目录。例如,将 spring.devtools.restart.exclude 设置为如下可排除对
/static,/public 目录的restart监测。

spring.devtools.restart.exclude=static/**,public/**

20.2.3 Disabling Restart

If you do not want to use the restart feature, you can disable it by using the spring.devtools.restart.enabled property. In most cases, you can set this property in your application.properties (doing so still initializes the restart classloader, but it does not watch for file changes).

如果您不想使用重新启动功能,则可以使用spring.devtools.restart.enabled属性将其禁用。 在大多数情况下,您可以在application.properties中设置此属性(这样做仍会初始化重新启动类加载器,但不会监视文件更改)。

If you need to completely disable restart support (for example, because it doesn’t work with a specific library), you need to set the spring.devtools.restart.enabled System property to false before calling SpringApplication.run(…​), as shown in the following example:

如果您需要完全禁用重新启动支持(例如,因为它不适用于特定的库),则需要在调用SpringApplication.run(...)之前将spring.devtools.restart.enabled 系统属性设置为false, 如以下示例所示:

public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(MyApp.class, args);
}


20.3 LiveReload
The spring-boot-devtools module includes an embedded LiveReload server that can be used to trigger a browser refresh when a resource is changed. LiveReload browser extensions are freely available for Chrome, Firefox and Safari from livereload.com. The

spring-boot-devtools module contains an embedded LiveReload server that can be used to trigger browser refreshes when resources change. Chrome, Firefox, and Safari supported by the LiveReload browser extension, available for free from livereload.com.

If you do not want to start the LiveReload server when your application runs, you can set the spring.devtools.livereload.enabled property to false. If you do not want to start the LiveReload server when your application runs, you can set the

spring.devtools.livereload The .enabled property is set to false.

[Note]
You can only run one LiveReload server at a time. Before starting your application, ensure that no other LiveReload servers are running. If you start multiple applications from your IDE, only the first has LiveReload support.

Only one LiveReload server can run at a time. Before starting your application, make sure no other LiveReload servers are running. If multiple applications are launched from the IDE, only the first one supports LiveReload.

Before making related settings, you need to introduce spring-boot-devtools dependencies.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325449005&siteId=291194637