druid-admin-spring-boot-starter

Provides cluster-based monitoring functionalities.

License

License

Categories

Categories

Spring Boot Container Microservices druid Data Databases
GroupId

GroupId

com.github.benfromchina
ArtifactId

ArtifactId

druid-admin-spring-boot-starter
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

druid-admin-spring-boot-starter
Provides cluster-based monitoring functionalities.
Project URL

Project URL

https://github.com/benfromchina/druid-admin-spring-boot-starter
Source Code Management

Source Code Management

https://github.com/benfromchina/druid-admin-spring-boot-starter.git

Download druid-admin-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.benfromchina/druid-admin-spring-boot-starter/ -->
<dependency>
    <groupId>com.github.benfromchina</groupId>
    <artifactId>druid-admin-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.benfromchina/druid-admin-spring-boot-starter/
implementation 'com.github.benfromchina:druid-admin-spring-boot-starter:1.0.0'
// https://jarcasting.com/artifacts/com.github.benfromchina/druid-admin-spring-boot-starter/
implementation ("com.github.benfromchina:druid-admin-spring-boot-starter:1.0.0")
'com.github.benfromchina:druid-admin-spring-boot-starter:jar:1.0.0'
<dependency org="com.github.benfromchina" name="druid-admin-spring-boot-starter" rev="1.0.0">
  <artifact name="druid-admin-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.benfromchina', module='druid-admin-spring-boot-starter', version='1.0.0')
)
libraryDependencies += "com.github.benfromchina" % "druid-admin-spring-boot-starter" % "1.0.0"
[com.github.benfromchina/druid-admin-spring-boot-starter "1.0.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.projectlombok : lombok jar
org.slf4j : slf4j-api jar
com.alibaba : druid jar 1.2.1
com.alibaba : fastjson jar 1.2.73
org.apache.commons : commons-collections4 jar 4.2
org.apache.commons : commons-lang3 jar
org.apache.httpcomponents : httpmime jar

provided (4)

Group / Artifact Type Version
org.springframework.boot : spring-boot-autoconfigure jar
org.springframework.boot : spring-boot-configuration-processor jar
org.springframework.cloud : spring-cloud-commons jar
javax.servlet : javax.servlet-api jar

Project Modules

There are no modules declared in this project.

目录

功能

  • 支持集群状态下的集群监控
  • 支持 Spring Boot 自动配置
  • 支持 eureka, consul, nacos 三种注册中心

效果展示

  • 微服务实例页面

    丑是丑了点,原谅一个 Java 后端没啥审美。

  • 首页

  • 数据源

  • SQL 监控

配置

  1. . pom.xml 中引入依赖
<dependency>
    <groupId>com.github.benfromchina</groupId>
    <artifactId>druid-admin-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>
<!-- druid 监控底层基于 servlet ,需要 web 模块支持 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>${spring-cloud.version}</version>
</dependency>
  • eureka 注册中心引入
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>${spring-cloud.version}</version>
</dependency>
  • nacos 注册中心引入
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    <version>${spring-cloud-alibaba.version}</version>
</dependency>
  1. yaml 中配置
  • eureka 注册中心
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 注册中心
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
  1. 客户端微服务配置
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/*
  1. 访问 uri /druid/service.html

项目实例

druid-admin-samples

Versions

Version
1.0.0