您当前的位置: 首页 >  ar

小志的博客

暂无认证

  • 0浏览

    0关注

    1217博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

spring boot访问Druid控制台页面报错 Sorry, you are not permitted to view this page.

小志的博客 发布时间:2020-10-19 21:00:14 ,浏览量:0

1、报错如下图: 在这里插入图片描述 2、配置如下:

spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        druid:
            driver-class-name: com.mysql.cj.jdbc.Driver
            url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
            username: 123123
            password: 123123
            initial-size: 10
            max-active: 100
            min-idle: 10
            max-wait: 60000
            pool-prepared-statements: true
            max-pool-prepared-statement-per-connection-size: 20
            time-between-eviction-runs-millis: 60000
            min-evictable-idle-time-millis: 300000
            #Oracle需要打开注释
            #validation-query: SELECT 1 FROM DUAL
            test-while-idle: true
            test-on-borrow: false
            test-on-return: false
            stat-view-servlet:
                enabled: true
                url-pattern: /druid/*
            filter:
                stat:
                    log-slow-sql: true
                    slow-sql-millis: 1000
                    merge-sql: false
                wall:
                    config:
                        multi-statement-allow: true

3、判断规则如下:

  • deny优先于allow,如果在deny列表中,就算在allow列表中,也会被拒绝。
  • 如果allow没有配置或者为空,则允许所有访问

4、解决步骤如下:

1)、只允许项目部署的那台机器可以访问连接池监控

  • spring.datasource.druid.stat-view-servlet.allow=127.0.0.1

2)、设置多个ip可以访问连接池监控 ,需要用 逗号分开

  • spring.datasource.druid.stat-view-servlet.allow=192.168.0.1,192.168.0.2

5、再次运行访问Druid控制台,效果如下:

在这里插入图片描述

关注
打赏
1661269038
查看更多评论
立即登录/注册

微信扫码登录

0.1997s