一、热部署
在开发中我们修改一个Java文件后想看到效果不得不重启应用,这导致大量时间花费,我们希望不重启应用的情况下,程序可以自动部署(热部署)。有以下四种情况,如何能实现热部署。
- 模板引擎
在Spring Boot中开发情况下禁用模板引擎的cache
页面模板改变ctrl+F9(重新编译)可以重新编译当前页面并生效
thymeleaf:
cache: false
-
JRebel
收费的一个热部署软件
安装插件使用即可 -
Spring Boot Devtools(推荐)
引入依赖即可使用
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
二、监控管理
通过引入spring-boot-starter-actuator,可以使用Spring Boot为我们提供的准生产环境下的应用监控和管理功能。我们可以通过HTTP,JMX,SSH协议来进行操作,自动得到审计、健康及指标信息等
使用步骤:
- 引入spring-boot-starter-actuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
#选择需要监控的端点
management.endpoints.web.exposure.include=*
- 通过http方式访问监控端点
shutdown端点可进行shutdown(应使用POST方法访问,此端点默认关闭) - 监控和管理端点
三、定制端点信息
- 定制端点一般通过endpoints+端点名+属性名来设置。
- 修改端点id(endpoints.beans.id=mybeans)
- 开启远程应用关闭功能(endpoints.shutdown.enabled=true)
- 关闭端点(endpoints.beans.enabled=false)
- 开启所需端点
endpoints.enabled=false
endpoints.beans.enabled=true - 定制端点访问根路径
management.context-path=/manage - 关闭http端点
management.port=-1