springboot后台服务搭建(四 整合druid)

总览:https://blog.****.net/qq_22037575/article/details/86687765

本文概要:springboot2.x 整合 druid

码云:https://gitee.com/RichterGit/****/tree/master/springboot-radmin/004/

目录

1.pom导入依赖

2.全局配置

3.访问


1.pom导入依赖

导入 druid依赖

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

 springboot后台服务搭建(四 整合druid)

 

2.全局配置

在 application.yml配置 druid

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/****_radmin?characterEncoding=utf8&useSSL=false&serverTimezone=UTC
    username: root
    password: 123456
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      initial-size: 10
      max-active: 20
      web-stat-filter:
        enabled: true
        url-pattern: /*
        exclusions: /druid/*
      stat-view-servlet:
        enabled: true
        reset-enable: true
        url-pattern: /druid/*
        allow: 127.0.0.1
        login-username: admin
        login-password: admin
      filter:
        wall:
          enabled: true
          db-type: mysql
          log-violation: true
          throw-exception: true

springboot后台服务搭建(四 整合druid) 

 

3.访问

访问 http://localhost:8080/radmin/druid/ 会自动跳转到 druid 的登录页 login.html

账号密码就是 application.yml的 login-username:admin 和 login-password:admin

springboot后台服务搭建(四 整合druid)

 springboot后台服务搭建(四 整合druid)

 springboot后台服务搭建(四 整合druid)

 因为服务器重新启动,所以还没有数据,这里我们来请求一下服务器

springboot后台服务搭建(四 整合druid)

 
springboot后台服务搭建(四 整合druid)

 springboot后台服务搭建(四 整合druid)