SpringBoot starter整合Druid数据源无法访问http://localhost:8080/druid

首先要保证下面的配置无误

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/eesy
    username: root
    password: qwer
    driver-class-name: com.mysql.jdbc.Driver

    druid:
      aop-patterns: com.marchsoft.admin.* # 配置要扫描的包
      filters: stat,wall # 配置监控防火墙

      stat-view-servlet: # 开启了statViewServlet功能,也就是监控页的配置
        enabled: true
        login-username: admin
        login-password: admin
        resetEnable: false

      web-stat-filter: # 监控web应用,开启web监控功能
        enabled: true
        urlPattern: /*
        exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'


      filter:
        stat:
          slow-sql-millis: 1000 #设置所有超过1000行的查询都是慢查询
          logSlowSql: true
          enabled: true
        wall: #开启防火墙的功能
          enabled: true
          config:
            drop-table-allow: false

如果上面的配置无误那么就看看pom配置文件是否将下面的代码

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.17</version>
        </dependency>

换成

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

注意:是换成

猜你喜欢

转载自blog.csdn.net/weixin_45566730/article/details/114188414
今日推荐