SpringBoot專案使用Actuator遠端關閉服務
阿新 • • 發佈:2020-08-04
1、在pom.xml檔案引入依賴
<!-- 執行狀態監控actuator依賴 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- Web 應用安全依賴 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
2、配置檔案配置
server: port: 8100 #web服務埠 servlet: context-path: /buzheng spring: main: allow-bean-definition-overriding: true #是否允許使用相同名稱重新註冊不同的bean實現. 預設是允許 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 # 為防止他人改動 security: user: name: buzheng password: buzheng ### 執行狀態監控Actuator management: server: port: 9011 #執行狀態監控埠 endpoints: web: exposure: include: "*" base-path: / #配置可遠端使用 Actuator 關閉服務 endpoint: shutdown: #關閉服務 enabled: true