SpringBoot應用 Automatic Restart以及靜態資源 livereload 設定
SpringBoot應用 Automatic Restart以及靜態資源 livereload 設定
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.
當類路徑上的檔案發生變化時,使用spring-boot-devtools的應用程式會自動重啟。 當在IDE中工作時,它為程式碼更改提供了一個非常快速的反饋迴圈,這是一個有用的功能。 預設情況下,路徑下的所有條目都將被監視是否更改。 但是,某些時候,有些資源(如靜態資產和檢視模板)的更改不需要重新啟動應用程式。
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.
spring-boot-devtools模組包含一個嵌入式LiveReload伺服器,當資源發生變化時,可用於觸發瀏覽器重新整理。 LiveReload瀏覽器擴充套件支援的Chrome,Firefox和Safari,可從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.
如果您不想在應用程式執行時啟動LiveReload伺服器,則可以將spring.devtools.livereload.enabled屬性設定為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.
一次只能執行一個LiveReload伺服器。 在開始您的應用程式之前,請確保沒有其他LiveReload伺服器正在執行。 如果從IDE啟動多個應用程式,則只有第一個支援LiveReload。
進行相關設定之前,要引入 spring-boot-devtools 依賴。
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.
當類路徑上的檔案發生變化時,使用spring-boot-devtools的應用程式會自動重啟。 當在IDE中工作時,它為程式碼更改提供了一個非常快速的反饋迴圈,這是一個有用的功能。 預設情況下,路徑下的所有條目都將被監視是否更改。 但是,某些時候,有些資源(如靜態資產和檢視模板)的更改不需要重新啟動應用程式。
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.
spring-boot-devtools模組包含一個嵌入式LiveReload伺服器,當資源發生變化時,可用於觸發瀏覽器重新整理。 LiveReload瀏覽器擴充套件支援的Chrome,Firefox和Safari,可從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.
如果您不想在應用程式執行時啟動LiveReload伺服器,則可以將spring.devtools.livereload.enabled屬性設定為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.
一次只能執行一個LiveReload伺服器。 在開始您的應用程式之前,請確保沒有其他LiveReload伺服器正在執行。 如果從IDE啟動多個應用程式,則只有第一個支援LiveReload。
進行相關設定之前,要引入 spring-boot-devtools 依賴。
相關文章
- springboot設定靜態資源不攔截的方法Spring Boot
- WPF:靜態、動態資源以及資源詞典
- SpringBoot處理靜態資源Spring Boot
- SpringBoot靜態資源訪問Spring Boot
- Springboot中如何訪問靜態資源Spring Boot
- 多頁應用增量更新靜態資源Webpack打包方案Web
- springboot+themeleaf+bootstrap訪問靜態資源/無法訪問靜態資源/圖片Spring Boot
- SpringBoot-靜態資源載入-原始碼Spring Boot原始碼
- springboot新增靜態資源無法訪問Spring Boot
- SpringBoot - 搭建靜態資源儲存伺服器Spring Boot伺服器
- SpringBoot之yaml語法及靜態資源訪問Spring BootYAML
- springboot專案所有靜態資源無法載入Spring Boot
- webpack 靜態資源管理Web
- Web靜態資源加速Web
- 靜態資源公共庫
- Ubuntu裡怎樣設定靜態IP?Ubuntu中設定靜態IP的方法Ubuntu
- centos 7 設定靜態ipCentOS
- OpenSUSE的靜態IP設定
- 靜態資源伺服器伺服器
- Websphere中靜態資源配置Web
- ubuntu15 設定靜態ipUbuntu
- PbootCMS偽靜態怎麼設定?boot
- 前端靜態資源快取最優解以及max-age的陷阱前端快取
- 使用electron-builder打包windows應用時的幾個靜態資源問題UIWindows
- 008.Nginx靜態資源Nginx
- 【Nginx】Nginx部署前端靜態資源Nginx前端
- 如何在nginx配置靜態資源Nginx
- win10靜態ip怎麼設定_win10設定靜態ip地址步驟Win10
- 華為路由器靜態ip怎麼設定?華為路由器靜態ip設定教程路由器
- 用node搭建簡單的靜態資源管理器
- 靜態應用程式安全測試
- 電腦靜態ip怎麼設定
- VirtualBox-Ubuntu設定靜態IPUbuntu
- Ubuntu 16.04 Server 設定靜態IPUbuntuServer
- Linux 設定靜態路由表Linux路由
- Linux下設定靜態IP地址Linux
- 帝國cms偽靜態設定方法
- debian 12設定靜態ip、dnsDNS