大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

SpringBoot教程
SpringBoot入門案例
SpringBoot框架Web開發(fā)
SpringBoot非web應(yīng)用程序
SpringBoot使用攔截器
SpringBoot中使用Servlet
SpringBoot中使用Filter
SpringBoot項(xiàng)目配置字符編碼
SpringBoot打包與部署
SpringBoot使用Actuator
SpringBoot集成Thymeleaf模板
SpringBoot總結(jié)及綜合案例
SpringBoot工程下使用Mybatis反向工程

SpringBoot使用Actuator

在生產(chǎn)環(huán)境中,需要實(shí)時(shí)或定期監(jiān)控服務(wù)的可用性,spring-Boot的Actuator 功能提供了很多監(jiān)控所需的接口。

Actuator是Spring Boot提供的對應(yīng)用系統(tǒng)的自省和監(jiān)控的集成功能,可以對應(yīng)用系統(tǒng)進(jìn)行配置查看、健康檢查、相關(guān)功能統(tǒng)計(jì)等,一般運(yùn)維人員使用多些,開發(fā)了解即可。

使用該功能步驟

我們這里監(jiān)控03-springboot-web程序

項(xiàng)目名稱:038-springboot-actuator

1.在項(xiàng)目pom.xml中添加SSM需要的依賴

<!--MyBatis集成SpringBoot框架的起步依賴-->
<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>2.0.0</version>
</dependency>

<!--連接MySQL的驅(qū)動-->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

<!-- 加載spring boot redis包 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

<!--SpringBoot項(xiàng)目內(nèi)嵌tomcat對jsp的解析包-->
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
</dependency>

2.在pom文件中添加Actuator需要的依賴

<!--Spring Boot Actuator依賴-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

3.編寫集成SSM在application.properties的配置


#設(shè)置內(nèi)嵌Tomcat端口號
server.port=9090
#設(shè)置項(xiàng)目上下文根
server.servlet.context-path=/038-springboot-actuator

#配置jsp的前/后綴
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp

#配置連接MySQL數(shù)據(jù)庫信息
spring.datasource.url=jdbc:mysql://192.168.92.134:3306/springboot?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=123456

#配置redis連接信息(單機(jī)模式)
spring.redis.host=192.168.92.134
spring.redis.port=6379
spring.redis.password=123456

4.在application.properties或application.yml配置文件中指定監(jiān)控的HTTP端口及路徑

我這里沒有進(jìn)行配置

• #服務(wù)運(yùn)行的端口

server.port=8080

server.servlet.context-path=/038-springboot-actuator

• #actuator監(jiān)控的端口(端口可配可不配,如果不配置,則使用和server.port相同的端口)

management.server.port=8100

• #actuator監(jiān)控的訪問上下文根路徑(路徑可配可不配,如果不配置,則使用和server.context-path相同的路徑)

management.server.servlet.context-path=/038-springboot-actuator

5.在application.properties或application.yml配置文件中設(shè)置開啟所有的端口

#默認(rèn)只開啟了health和info,設(shè)置為*,則包含所有的web入口端點(diǎn)
management.endpoints.web.exposure.include=*

6.啟動MySQL

7.啟動Redis

8.啟動038-springboot-actuator

① 瀏覽器訪問http://localhost:9090/actuator/health

② 瀏覽器訪問http://localhost:9090/actuator/info

默認(rèn)沒有內(nèi)容

需要自己在application.properties配置文件中添加信息,需要以info開頭,后面的內(nèi)容可以自己設(shè)定,一般配置項(xiàng)目的版權(quán)等信息,例如

#配置項(xiàng)目版權(quán)相關(guān)信息
info.contact.email=bjpowernode@163.com
info.contact.phone=010-84846003

配置完畢后,重啟項(xiàng)目再進(jìn)行訪問

Actuator提供的主要功能

HTTP方法

路徑

描述

GET

/configprops

查看配置屬性,包括默認(rèn)配置
http://www.haojson.com
json進(jìn)行格式化

GET

/beans

查看Spring容器目前初始化的bean及其關(guān)系列表

GET

/env

查看所有環(huán)境變量

GET

/mappings

查看所有url映射

GET

/health

查看應(yīng)用健康指標(biāo)

GET

/info

查看應(yīng)用信息

GET

/metrics

查看應(yīng)用基本指標(biāo)

GET

/metrics/{name}

查看具體指標(biāo)

JMX

/shutdown

關(guān)閉應(yīng)用

shutdown的使用

注意:/shutdown不能直接在瀏覽器中訪問

• 先在pom.xml文件中配置


# 啟用關(guān)閉springboot的服務(wù) 
# 關(guān)閉SpringBoot服務(wù)是否可用,true讓其關(guān)閉服務(wù)可用,默認(rèn)為不可用
management.endpoint.shutdown.enabled=true

• 雙擊打開jconsole

• 選擇Spring Boot進(jìn)程,進(jìn)行連接管理

•  點(diǎn)擊shutdown,可關(guān)閉Spring Boot服務(wù)

 

全部教程
主站蜘蛛池模板: 福利在线不卡 | 久久久亚洲国产精品主播 | 婷婷在线免费视频 | 亚洲大片在线观看 | 婷婷啪啪| 国内视频一区 | 国产一区二区在线观看免费 | 精品一区二区三区在线成人 | 男女www| 5060网永久免费一级毛片 | 福利视频网 | 狼狼色丁香久久婷婷综合五月 | 亚洲美日韩 | 黄色片在线观看网站 | 欧美金8天国 | 精品久久一区 | 日韩欧美精品一区二区 | 色综合久久88中文字幕 | 精品亚洲大全 | 欧美成 人激情视频 | 精品91视频 | 青青青国产精品国产精品久久久久 | 性欧美视频在线观看 | chinese456老人gay chinese国产xxxx中国 | 欧美男女性生活视频 | 中文字幕视频不卡 | 91亚洲精品久久91 | 欧美综合图区亚欧综合图区 | 久久久久青草 | 视频一区日韩 | 久久99蜜桃精品久久久久小说 | 日韩欧美视频一区 | 欧美一级成人毛片影院 | 爱唯侦察1024入口地址 | 国产精品国产国产aⅴ | 日韩字幕 | 天天插夜夜 | 久草在线免费资源 | 人成在线免费视频 | 欧美日韩中文字幕在线观看 | 欧美视频一区二区专区 |