Springboot + druid + 監控頁面

實現下面配置,然後訪問
http://localhost:服務端口/項目名/druid/login.html

pom.xml

		<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.21</version>
        </dependency>

application.yml

  datasource:
    name: era
    url: jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useSSL=false
    username: root
    password: root
    # 使用druid數據源
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    # 下面爲連接池的補充設置,應用到上面所有數據源中
    druid:
    # 初始化大小,最小,最大
      initialSize: 5
      minIdle: 5
      maxActive: 20
      # 配置獲取連接等待超時的時間
      maxWait: 60000
      # 配置間隔多久才進行一次檢測,檢測需要關閉的空閒連接,單位是毫秒
      timeBetweenEvictionRunsMillis: 60000
      # 配置一個連接在池中最小生存的時間,單位是毫秒
      minEvictableIdleTimeMillis: 300000
      validationQuery: SELECT 1 FROM DUAL
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 打開PSCache,並且指定每個連接上PSCache的大小, oracle設爲true,mysql設爲false。分庫分表較多推薦設置爲false
      poolPreparedStatements: false
      maxPoolPreparedStatementPerConnectionSize: 20
      filters: stat,wall,log4j2
      # Spring監控AOP切入點,如x.y.z.service.*,配置多個英文逗號分隔
#      aop-patterns: com.gdpt.pos.service.*
      # WebStatFilter配置
      web-stat-filter:
        enabled: true
        # 添加過濾規則
        url-pattern: /*
        # 忽略過濾的格式
        exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
      # StatViewServlet配置
      stat-view-servlet:
        enabled: true
        # 訪問路徑爲/druid時,跳轉到StatViewServlet
        url-pattern: /druid/*
        # 是否能夠重置數據
        reset-enable: false
        # 需要賬號密碼才能訪問控制檯
        login-username: admin
        login-password: 123456
        # IP白名單
        # allow: 127.0.0.1
        # IP黑名單(共同存在時,deny優先於allow)
        # deny: 192.168.1.218

      # 配置StatFilter
      filter:
        stat:
          log-slow-sql: true

訪問http://localhost:8080/項目名/druid/login.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章