# druid-admin-spring-boot-starter **Repository Path**: jarvis-lib/druid-admin-spring-boot-starter ## Basic Information - **Project Name**: druid-admin-spring-boot-starter - **Description**: Druid 集群监控 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 12 - **Forks**: 2 - **Created**: 2021-01-26 - **Last Updated**: 2024-09-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: druid, 集群监控, SpringCloud ## README [![](https://img.shields.io/badge/maven%20central-v2.0.1-brightgreen)](https://mvnrepository.com/artifact/com.github.benfromchina/druid-admin-spring-boot-starter) [![](https://img.shields.io/badge/release-v2.0.1-blue)](https://gitee.com/jarvis-lib/druid-admin-spring-boot-starter/releases/v2.0.1) [![](https://img.shields.io/badge/license-Apache--2.0-9cf)](https://www.apache.org/licenses/LICENSE-2.0.html) # 目录 - [功能](#功能) - [效果展示](#效果展示) - [配置](#配置) - [项目实例](#项目实例) # 功能 - 支持集群状态下的集群监控 - 支持 Spring Boot 自动配置 - 支持 eureka, consul, nacos 三种注册中心 - 1.0 版本支持 jdk17 以下 - 2.0 版本支持 jdk17 及以上 # 效果展示 - 微服务实例页面 `丑是丑了点,原谅一个 Java 后端没啥审美。` - 首页 - 数据源 - SQL 监控 # 配置 1. . pom.xml 中引入依赖 ```xml io.github.benfromchina druid-admin-spring-boot-starter 2.0.1 org.springframework.boot spring-boot-starter-web ${spring-cloud.version} ``` - eureka 注册中心引入 ```xml org.springframework.cloud spring-cloud-starter-netflix-eureka-client ${spring-cloud.version} ``` - nacos 注册中心引入 ```xml com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery ${spring-cloud-alibaba.version} ``` 2. yaml 中配置 - eureka 注册中心 ```yml spring: datasource: druid: admin: login-username: user login-password: 123456 applications: # 需要监控的微服务名,默认为 spring.application.name - escloud-service-elk - escloud-service-manager - escloud-service-ocr - escloud-service-user eureka: instance: prefer-ip-address: true lease-renewal-interval-in-seconds: 5 lease-expiration-duration-in-seconds: 15 client: service-url: defaultZone: http://192.168.22.146:7001/eureka ``` - nacos 注册中心 ```yml spring: cloud: nacos: server-addr: 192.168.22.100:8848 # 单机 nacos 地址,或 nacos 集群虚拟 IP datasource: druid: admin: login-username: user login-password: 123456 applications: # 需要监控的微服务名,默认为 spring.application.name - escloud-service-elk - escloud-service-manager - escloud-service-ocr - escloud-service-user ``` 3. 客户端微服务配置 ```yml spring: datasource: druid: filter: stat: enabled: true web-stat-filter: enabled: true url-pattern: /* exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' stat-view-servlet: enabled: true allow: '' # ''表示允许所有地址访问,默认只能本服务访问 url-pattern: /druid/* ``` 4. 访问 uri `/druid/service.html` # 项目实例 [druid-admin-samples](https://gitee.com/jarvis-lib/druid-admin-samples)