springboot-热部署

news2024/11/27 0:25:53

什么是热部署

事先我创建一个springboot项目,引入web依赖。

当我冷启动的时候,日志如下:

D:\tools\jdk-17.0.3\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:D:\tools\IDEA\lib\idea_rt.jar=6005:D:\tools\IDEA\bin -Dfile.encoding=UTF-8 -classpath E:\java\springboot\project_course\hot-start\target\classes;D:\repository\org\springframework\boot\spring-boot-devtools\3.0.2\spring-boot-devtools-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot\3.0.2\spring-boot-3.0.2.jar;D:\repository\org\springframework\spring-context\6.0.4\spring-context-6.0.4.jar;D:\repository\org\springframework\boot\spring-boot-autoconfigure\3.0.2\spring-boot-autoconfigure-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot-starter-web\3.0.2\spring-boot-starter-web-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot-starter\3.0.2\spring-boot-starter-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot-starter-logging\3.0.2\spring-boot-starter-logging-3.0.2.jar;D:\repository\ch\qos\logback\logback-classic\1.4.5\logback-classic-1.4.5.jar;D:\repository\ch\qos\logback\logback-core\1.4.5\logback-core-1.4.5.jar;D:\repository\org\apache\logging\log4j\log4j-to-slf4j\2.19.0\log4j-to-slf4j-2.19.0.jar;D:\repository\org\apache\logging\log4j\log4j-api\2.19.0\log4j-api-2.19.0.jar;D:\repository\org\slf4j\jul-to-slf4j\2.0.6\jul-to-slf4j-2.0.6.jar;D:\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;D:\repository\org\yaml\snakeyaml\1.33\snakeyaml-1.33.jar;D:\repository\org\springframework\boot\spring-boot-starter-json\3.0.2\spring-boot-starter-json-3.0.2.jar;D:\repository\com\fasterxml\jackson\core\jackson-databind\2.14.1\jackson-databind-2.14.1.jar;D:\repository\com\fasterxml\jackson\core\jackson-annotations\2.14.1\jackson-annotations-2.14.1.jar;D:\repository\com\fasterxml\jackson\core\jackson-core\2.14.1\jackson-core-2.14.1.jar;D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.14.1\jackson-datatype-jdk8-2.14.1.jar;D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.14.1\jackson-datatype-jsr310-2.14.1.jar;D:\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.14.1\jackson-module-parameter-names-2.14.1.jar;D:\repository\org\springframework\boot\spring-boot-starter-tomcat\3.0.2\spring-boot-starter-tomcat-3.0.2.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.5\tomcat-embed-core-10.1.5.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.5\tomcat-embed-el-10.1.5.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.5\tomcat-embed-websocket-10.1.5.jar;D:\repository\org\springframework\spring-web\6.0.4\spring-web-6.0.4.jar;D:\repository\org\springframework\spring-beans\6.0.4\spring-beans-6.0.4.jar;D:\repository\io\micrometer\micrometer-observation\1.10.3\micrometer-observation-1.10.3.jar;D:\repository\io\micrometer\micrometer-commons\1.10.3\micrometer-commons-1.10.3.jar;D:\repository\org\springframework\spring-webmvc\6.0.4\spring-webmvc-6.0.4.jar;D:\repository\org\springframework\spring-aop\6.0.4\spring-aop-6.0.4.jar;D:\repository\org\springframework\spring-expression\6.0.4\spring-expression-6.0.4.jar;D:\repository\org\slf4j\slf4j-api\2.0.6\slf4j-api-2.0.6.jar;D:\repository\org\springframework\spring-core\6.0.4\spring-core-6.0.4.jar;D:\repository\org\springframework\spring-jcl\6.0.4\spring-jcl-6.0.4.jar cn.oesoft.hotstart.HotStartApplication
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.2)

2023-05-11T15:40:21.186+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Starting HotStartApplication using Java 17.0.3 with PID 18892 (E:\java\springboot\project_course\hot-start\target\classes started by Administrator in E:\java\springboot\project_course\hot-start)
2023-05-11T15:40:21.186+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : No active profile set, falling back to 1 default profile: "default"
2023-05-11T15:40:21.273+08:00  INFO 18892 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-05-11T15:40:21.273+08:00  INFO 18892 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : An older version [1.2.36] of the Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of [2.0.1]
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : Loaded Apache Tomcat Native library [1.2.36] using APR version [1.7.2].
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.1.1t  7 Feb 2023]
2023-05-11T15:40:22.561+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-05-11T15:40:22.561+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.5]
2023-05-11T15:40:22.639+08:00  INFO 18892 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-05-11T15:40:22.639+08:00  INFO 18892 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1366 ms
2023-05-11T15:40:22.890+08:00  INFO 18892 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2023-05-11T15:40:23.015+08:00  INFO 18892 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2023-05-11T15:40:23.078+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-05-11T15:40:23.094+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Started HotStartApplication in 2.455 seconds (process running for 3.9)
ccc

当我修改了两个Java类,一个是启动类,使它输出aaa,不再是ccc,一个是controller类,热部署的日志如下:

D:\tools\jdk-17.0.3\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:D:\tools\IDEA\lib\idea_rt.jar=6005:D:\tools\IDEA\bin -Dfile.encoding=UTF-8 -classpath E:\java\springboot\project_course\hot-start\target\classes;D:\repository\org\springframework\boot\spring-boot-devtools\3.0.2\spring-boot-devtools-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot\3.0.2\spring-boot-3.0.2.jar;D:\repository\org\springframework\spring-context\6.0.4\spring-context-6.0.4.jar;D:\repository\org\springframework\boot\spring-boot-autoconfigure\3.0.2\spring-boot-autoconfigure-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot-starter-web\3.0.2\spring-boot-starter-web-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot-starter\3.0.2\spring-boot-starter-3.0.2.jar;D:\repository\org\springframework\boot\spring-boot-starter-logging\3.0.2\spring-boot-starter-logging-3.0.2.jar;D:\repository\ch\qos\logback\logback-classic\1.4.5\logback-classic-1.4.5.jar;D:\repository\ch\qos\logback\logback-core\1.4.5\logback-core-1.4.5.jar;D:\repository\org\apache\logging\log4j\log4j-to-slf4j\2.19.0\log4j-to-slf4j-2.19.0.jar;D:\repository\org\apache\logging\log4j\log4j-api\2.19.0\log4j-api-2.19.0.jar;D:\repository\org\slf4j\jul-to-slf4j\2.0.6\jul-to-slf4j-2.0.6.jar;D:\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;D:\repository\org\yaml\snakeyaml\1.33\snakeyaml-1.33.jar;D:\repository\org\springframework\boot\spring-boot-starter-json\3.0.2\spring-boot-starter-json-3.0.2.jar;D:\repository\com\fasterxml\jackson\core\jackson-databind\2.14.1\jackson-databind-2.14.1.jar;D:\repository\com\fasterxml\jackson\core\jackson-annotations\2.14.1\jackson-annotations-2.14.1.jar;D:\repository\com\fasterxml\jackson\core\jackson-core\2.14.1\jackson-core-2.14.1.jar;D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.14.1\jackson-datatype-jdk8-2.14.1.jar;D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.14.1\jackson-datatype-jsr310-2.14.1.jar;D:\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.14.1\jackson-module-parameter-names-2.14.1.jar;D:\repository\org\springframework\boot\spring-boot-starter-tomcat\3.0.2\spring-boot-starter-tomcat-3.0.2.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.5\tomcat-embed-core-10.1.5.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.5\tomcat-embed-el-10.1.5.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.5\tomcat-embed-websocket-10.1.5.jar;D:\repository\org\springframework\spring-web\6.0.4\spring-web-6.0.4.jar;D:\repository\org\springframework\spring-beans\6.0.4\spring-beans-6.0.4.jar;D:\repository\io\micrometer\micrometer-observation\1.10.3\micrometer-observation-1.10.3.jar;D:\repository\io\micrometer\micrometer-commons\1.10.3\micrometer-commons-1.10.3.jar;D:\repository\org\springframework\spring-webmvc\6.0.4\spring-webmvc-6.0.4.jar;D:\repository\org\springframework\spring-aop\6.0.4\spring-aop-6.0.4.jar;D:\repository\org\springframework\spring-expression\6.0.4\spring-expression-6.0.4.jar;D:\repository\org\slf4j\slf4j-api\2.0.6\slf4j-api-2.0.6.jar;D:\repository\org\springframework\spring-core\6.0.4\spring-core-6.0.4.jar;D:\repository\org\springframework\spring-jcl\6.0.4\spring-jcl-6.0.4.jar cn.oesoft.hotstart.HotStartApplication
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.2)

2023-05-11T15:40:21.186+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Starting HotStartApplication using Java 17.0.3 with PID 18892 (E:\java\springboot\project_course\hot-start\target\classes started by Administrator in E:\java\springboot\project_course\hot-start)
2023-05-11T15:40:21.186+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : No active profile set, falling back to 1 default profile: "default"
2023-05-11T15:40:21.273+08:00  INFO 18892 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-05-11T15:40:21.273+08:00  INFO 18892 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : An older version [1.2.36] of the Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of [2.0.1]
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : Loaded Apache Tomcat Native library [1.2.36] using APR version [1.7.2].
2023-05-11T15:40:22.545+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.1.1t  7 Feb 2023]
2023-05-11T15:40:22.561+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-05-11T15:40:22.561+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.5]
2023-05-11T15:40:22.639+08:00  INFO 18892 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-05-11T15:40:22.639+08:00  INFO 18892 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1366 ms
2023-05-11T15:40:22.890+08:00  INFO 18892 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2023-05-11T15:40:23.015+08:00  INFO 18892 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2023-05-11T15:40:23.078+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-05-11T15:40:23.094+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Started HotStartApplication in 2.455 seconds (process running for 3.9)
ccc
2023-05-11T15:53:21.057+08:00  INFO 18892 --- [   File Watcher] rtingClassPathChangeChangedEventListener : Restarting due to 2 class path changes (0 additions, 2 deletions, 0 modifications)
2023-05-11T15:53:21.135+08:00  INFO 18892 --- [       Thread-5] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.2)

2023-05-11T15:53:21.259+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Starting HotStartApplication using Java 17.0.3 with PID 18892 (E:\java\springboot\project_course\hot-start\target\classes started by Administrator in E:\java\springboot\project_course\hot-start)
2023-05-11T15:53:21.259+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : No active profile set, falling back to 1 default profile: "default"
2023-05-11T15:53:21.615+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-05-11T15:53:21.615+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : An older version [1.2.36] of the Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of [2.0.1]
2023-05-11T15:53:21.615+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : Loaded Apache Tomcat Native library [1.2.36] using APR version [1.7.2].
2023-05-11T15:53:21.615+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.1.1t  7 Feb 2023]
2023-05-11T15:53:21.615+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-05-11T15:53:21.615+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.5]
2023-05-11T15:53:21.633+08:00  INFO 18892 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-05-11T15:53:21.633+08:00  INFO 18892 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 374 ms
2023-05-11T15:53:21.725+08:00  INFO 18892 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2023-05-11T15:53:21.788+08:00  INFO 18892 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2023-05-11T15:53:21.804+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-05-11T15:53:21.819+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Started HotStartApplication in 0.612 seconds (process running for 782.628)
2023-05-11T15:53:21.819+08:00  INFO 18892 --- [  restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
ccc
2023-05-11T15:53:24.225+08:00  INFO 18892 --- [   File Watcher] rtingClassPathChangeChangedEventListener : Restarting due to 2 class path changes (2 additions, 0 deletions, 0 modifications)
2023-05-11T15:53:24.272+08:00  INFO 18892 --- [       Thread-7] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.2)

2023-05-11T15:53:24.366+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Starting HotStartApplication using Java 17.0.3 with PID 18892 (E:\java\springboot\project_course\hot-start\target\classes started by Administrator in E:\java\springboot\project_course\hot-start)
2023-05-11T15:53:24.366+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : No active profile set, falling back to 1 default profile: "default"
2023-05-11T15:53:24.660+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-05-11T15:53:24.660+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : An older version [1.2.36] of the Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of [2.0.1]
2023-05-11T15:53:24.660+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : Loaded Apache Tomcat Native library [1.2.36] using APR version [1.7.2].
2023-05-11T15:53:24.660+08:00  INFO 18892 --- [  restartedMain] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.1.1t  7 Feb 2023]
2023-05-11T15:53:24.660+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-05-11T15:53:24.660+08:00  INFO 18892 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.5]
2023-05-11T15:53:24.676+08:00  INFO 18892 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-05-11T15:53:24.676+08:00  INFO 18892 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 294 ms
2023-05-11T15:53:24.740+08:00  INFO 18892 --- [  restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2023-05-11T15:53:24.785+08:00  INFO 18892 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2023-05-11T15:53:24.801+08:00  INFO 18892 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2023-05-11T15:53:24.801+08:00  INFO 18892 --- [  restartedMain] cn.oesoft.hotstart.HotStartApplication   : Started HotStartApplication in 0.465 seconds (process running for 785.615)
2023-05-11T15:53:24.801+08:00  INFO 18892 --- [  restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
aaa

分析如下:

热部署始终使用同一个进程,冷启动创建一个新的进程。在热部署例子中,修改了两个类,但类路径上是先删除后增加两个字节码文件,导致两次热部署,但明显用时比冷启动要短。在类路径上删除启动类字节码后,热部署时不会删除它,要是删除它,应用就运行不了,但删除controller类字节码后,热部署时spring容器就会删除它,导致某段时间访问时,出现404。

结论:

热部署就是重启:自定义开发代码,包括类、页面、配置文件等,加载位置是restart类加载器。

冷启动的话还包括重载:jar包,加载位置是base类加载器。 

如何实现热部署

springboot使用内嵌的Tomcat,Tomcat也是spring容器的一个对象,那么这个对象如何知道自定义代码发生了变化?需要有个工具帮助它,如下:

在pom文件中添加spring-boot-devtools热部署依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
</dependency>

手动热部署:

build-》build project,激活热部署

自动热部署:

设置自动构建

eclipse:

idea:

IDEA配置热部署_idea热部署配置_微风粼粼的博客-CSDN博客

1、file-》settings-》build..-》compiler->build project automatically

2、ctrl+Alt+shift+/ ->registry...->选中compiler.automake.allow.when.app.running(如果存在)  

激活方式:焦点离开idea 5秒后 重启

热部署测试

修改HelloController的方法的返回值

热部署配置范围

默认不触发重启的目录列表

/META-INF/maven

/META-INF/resources

/resources

/static

/public

/templates

设置不触发重启的项

spring.devtools.restart.exclude=config/application.properties,static/**

禁用热部署

spring.devtools.restart.enabled=false

由于其他人也会通过配置启用热部署,导致自己的配置失效,那么我们可以在更高一层配置。

先看下属性加载优先顺序(由低到高)
参看 https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config

 我们可以通过第六级完成更高一层的配置

@SpringBootApplication
public class HotStartApplication {

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

}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/513377.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【神经网络】tensorflow -- 期中测试试题

题目一&#xff1a;&#xff08;20分&#xff09; 请使用Matplotlib中的折线图工具&#xff0c;绘制正弦和余弦函数图像&#xff0c;其中x的取值范围是&#xff0c;效果如图1所示。 要求&#xff1a; (1)正弦图像是蓝色曲线&#xff0c;余弦图像是红色曲线&#xff0c;线条宽度…

洛谷B2097 最长平台

最长平台 题目描述 对于一个数组&#xff0c;其连续的相同段叫做一个平台&#xff0c;例如&#xff0c;在 1 1 1&#xff0c; 2 2 2&#xff0c; 2 2 2&#xff0c; 3 3 3&#xff0c; 3 3 3&#xff0c; 3 3 3&#xff0c; 4 4 4&#xff0c; 5 5 5&#xff0c; 5 5 5&…

加密解密软件VMProtect入门使用教程(四):准备项目

VMProtect是新一代软件保护实用程序。VMProtect支持德尔菲、Borland C Builder、Visual C/C、Visual Basic&#xff08;本机&#xff09;、Virtual Pascal和XCode编译器。 同时&#xff0c;VMProtect有一个内置的反汇编程序&#xff0c;可以与Windows和Mac OS X可执行文件一起…

【2023 年第三届长三角高校数学建模竞赛】B 题 长三角新能源汽车发展与双碳关系研究 新能源汽车销售相关数据160M+下载

【2023 年第三届长三角高校数学建模竞赛】B 题 长三角新能源汽车发展与双碳关系研究 新能源汽车销售相关数据160M下载 1 题目 《节能与新能源汽车技术路线图 2.0》提出至 2035 年&#xff0c;新能源汽车市场占比超过 50%&#xff0c;燃料电池汽车保有量达到 100 万辆&#xff…

想做外贸却没有头绪?来看看这篇文章

海关总署公布最新数据&#xff1a;今年前4个月&#xff0c;我国外贸进出口总值13.32万亿元&#xff0c;同比增长5.8%&#xff0c;其中出口7.67万亿元&#xff0c;同比增长10.6%&#xff1b;进口5.65万亿元&#xff0c;同比增长0.02%。月度调查显示&#xff0c;出口订单增加的企…

图解LeetCode——238. 除自身以外数组的乘积

一、题目 给你一个整数数组 nums&#xff0c;返回 数组 answer &#xff0c;其中 answer[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积 。 题目数据 保证 数组 nums之中任意元素的全部前缀元素和后缀的乘积都在 32 位 整数范围内。 请不要使用除法&#xff0c;且在 O(n…

SoringBoot——pom文件:starter

先来看一看&#xff1a; 这次我们来介绍SpringBoot的pom文件的另一个好玩的地方&#xff1a;starter。 starter的中文含义是启动器&#xff0c;所以有时候我们在Maven仓库找依赖的时候&#xff0c;如果开启了自动翻译就会经常会看见一个奇怪的词叫做某某弹簧启动器&#xff0…

2023年河北沃克高位承重货架最新中标项目|中国沈阳某大型集团高位重型横梁式货架项目建设初期

【项目名称】高位重型横梁式货架项目 【承建单位】河北沃克金属制品有限公司 【合作客户】中国沈阳某大型集团 【建设时间】2023年5月上旬 【建设地域】中国沈阳地区 【项目客户需求】 本次沈阳高位重型横梁式货架项目合作的沈阳某大型集团中国变压器行业规模最大的制造企…

AIGC的发展与机遇

陈老老老板&#x1f9b8; &#x1f468;‍&#x1f4bb;本文专栏&#xff1a;赠书活动专栏&#xff08;为大家争取的福利&#xff0c;免费送书&#xff09;试一下文末赠书&#xff0c;讲一些科普类的知识 &#x1f468;‍&#x1f4bb;本文简述&#xff1a;本篇内容的引用都已征…

Protobuf: 高效数据传输的秘密武器

当涉及到网络通信和数据存储时&#xff0c;数据序列化一直都是一个重要的话题&#xff1b;特别是现在很多公司都在推行微服务&#xff0c;数据序列化更是重中之重&#xff0c;通常会选择使用 JSON 作为数据交换格式&#xff0c;且 JSON 已经成为业界的主流。但是 Google 这么大…

《理解了实现再谈网络性能》读书笔记

文章目录 内核是如何接收网络包的1.1 Linux⽹络收包总览1.2 linux 启动创建ksoftirqd进程网络子系统初始化协议栈注册网卡驱动初始化启动网卡 1.3 迎接数据的到来硬中断处理ksoftirqd 内核线程处理软中断网络协议栈处理IP协议层处理 完整流程 内核是如何接收网络包的 1.1 Linu…

使用阿里云服务器建站WordPress博客网站上线全流程

使用阿里云服务器快速搭建网站教程&#xff0c;先为云服务器安装宝塔面板&#xff0c;然后在宝塔面板上新建站点&#xff0c;阿里云服务器网以搭建WordPress网站博客为例&#xff0c;来详细说下从阿里云服务器CPU内存配置选择、Web环境、域名解析到网站上线全流程&#xff1a; …

常见概率分布及图像

概率分布 文章目录 概率分布[toc]1 离散概率分布1.1 伯努利分布1.2 二项分布1.3 泊松分布 2 连续概率分布2.1 均匀分布2.2 指数分布2.3 正态分布2.4 卡方分布2.5 Student分布3.5 F分布 1 离散概率分布 1.1 伯努利分布 随机变量 X X X仅取两个值&#xff0c; X 0 , 1 X0,1 X0…

【2023 年第三届长三角高校数学建模竞赛】C 题 考研难度知多少 考研情况相关数据下载

【2023 年第三届长三角高校数学建模竞赛】C 题 考研难度知多少 1 题目 C 题 考研难度知多少 据相关媒体报道&#xff0c;2023 年考研可以称得上是“最难”的一年&#xff0c;全国研究生报考人数突破新高达到 474 万人、部分考研学生感染新冠带病赴考、保研名额增多 挤压考研…

依次判断数组a1中的每个元素是否小于数组a2中对应位置的每个元素numpy.less()

【小白从小学Python、C、Java】 【计算机等考500强证书考研】 【Python-数据分析】 依次判断数组a1中的每个元素 是否小于数组a2中对应位置的每个元素 numpy.less() 选择题 以下程序的运行结果是? import numpy as np a1np.array([1,2,3]) a2np.array([3,2,1]) print("【…

消息推送平台的实时数仓?flink消费kafka消息入到hive

上一次比较大的更新是做了austin的预览地址&#xff0c;把企业微信的应用和机器人消息各种的消息类型和功能给完善了。上一篇文章也提到了&#xff0c;austin常规的功能已经更新得差不多了&#xff0c;剩下的就是各种细节的完善。 不知道大家还记不记得我当时规划austin时&…

免费使用的在线Axure原型工具找到了!

在线 Axure 工具替代即时设计&#xff0c;不需要安装插件&#xff0c;直接在浏览器中打开 Axure 原型文件&#xff0c;操作更加便捷。除了支持 Axure&#xff0c;即时设计还兼容 Figma、Sketch、AdobeXD 等更多文件类型&#xff0c;可用于线框设计、UI/UX 设计、原型交互、免切…

linux内核:笔记3-网络数据包收发流程

1.网络分层中&#xff0c;内核协议栈负责实现网络层和传输层 2.内核对用户进程提供socket接口用以调用 3.Linux内核包含链路层驱动用来驱动网络设备 4.内核网络层用来实现IP、ICMP以及IGMP 5.内核层传输层用来实现TCP和udp协议 6.内核源码中网络设备驱动对应的代码位于dri…

KDZD-100A触摸屏回路电阻测试仪

一、简介 测试仪是根据电力执行标准DL/T845.4-2004&#xff0c;采用高频开关电源技术和数字电路技术相结合设计而成。它适用于开关控制设备回路电阻的测量。其测试电流采用国家标准推荐的直流100A。可在电流100A的情况下直接测得回路电阻&#xff0c;并用数字显示出来。测量准确…

劝你们不要去外包,两年外包生涯做完,感觉自己废了一半....

先说一下自己的情况。大专生&#xff0c;17年通过校招进入湖南某软件公司&#xff0c;干了接近5年的点点点&#xff0c;今年年上旬&#xff0c;感觉自己不能够在这样下去了&#xff0c;长时间呆在一个舒适的环境会让一个人堕落&#xff01;而我已经在一个企业干了五年的功能测试…