SpringBoot基于Actuator遠程關閉服務
更新時間:2020年11月23日 09:41:51 作者:_不正
這篇文章主要介紹了SpringBoot基于Actuator遠程關閉服務,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
1、在pom.xml文件引入依賴
<!-- 運行狀態(tài)監(jiān)控actuator依賴 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2、配置文件配置
server:
port: 8100 #web服務端口
servlet:
context-path: /buzheng
spring:
main:
allow-bean-definition-overriding: true #是否允許使用相同名稱重新注冊不同的bean實現(xiàn). 默認是允許
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: asdfghjkl
### 運行狀態(tài)監(jiān)控Actuator
management:
server:
port: 9011 #運行狀態(tài)監(jiān)控端口
endpoints:
web:
exposure:
include: "*"
base-path: /
#配置可遠程使用 Actuator 關閉服務
endpoint:
shutdown: #關閉服務
enabled: true
3、執(zhí)行關閉指令
http://localhost:9011/shutdown POST請求
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
詳解Spring 框架中切入點 pointcut 表達式的常用寫法
這篇文章主要介紹了詳解Spring 框架中切入點 pointcut 表達式的常用寫法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04
java基于jedisLock—redis分布式鎖實現(xiàn)示例代碼
這篇文章主要介紹了jedisLock—redis分布式鎖實現(xiàn)示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-11-11
Springboot多數(shù)據(jù)源配置之整合dynamic-datasource方式
這篇文章主要介紹了Springboot多數(shù)據(jù)源配置之整合dynamic-datasource方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-03-03

