springboot集成Druid数据库连接池和监控
引入必要依赖
PS:建议不要引官方文档中的1.1.8版本,在私服中的1.1.8版本貌似没有DruidDataSourceBuilder类。。可能是我没有配置对。。
//数据源 compile 'com.alibaba:druid-spring-boot-starter:1.1.2' compile 'mysql:mysql-connector-java:6.0.6' //配置mybatis compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1"
配置 applocation.properties
#数据库连接信息 spring.datasource.druid.url=jdbc:mysql://127.0.0.1:3306/takin_write spring.datasource.druid.username=murasakiseifu spring.datasource.druid.password=123456 spring.datasource.druid.filters= stat spring.datasource.druid.initial-size=5 spring.datasource.druid.max-active=21 spring.datasource.druid.min-idle=6 spring.datasource.druid.max-wait=100 #WebStatFilter配置,说明请参考Druid Wiki,配置_配置WebStatFilter // 添加过滤规则 spring.datasource.druid.web-stat-filter.url-pattern=/* // 添加不需要忽略的格式信息 spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid2/* #spring.datasource.druid.web-stat-filter.session-stat-enable= #spring.datasource.druid.web-stat-filter.session-stat-max-count= #spring.datasource.druid.web-stat-filter.principal-session-name= #spring.datasource.druid.web-stat-filter.principal-cookie-name= #spring.datasource.druid.web-stat-filter.profile-enable= # StatViewServlet配置,说明请参考Druid Wiki,配置_StatViewServlet配置 #spring.datasource.druid.stat-view-servlet.enabled= #是否启用StatViewServlet默认值true # 自定义监控页面路径 spring.datasource.druid.stat-view-servlet.url-pattern=/druid/* # 是否开启重置按钮功能 spring.datasource.druid.stat-view-servlet.reset-enable=false # 登录账号 spring.datasource.druid.stat-view-servlet.login-username=admin # 登录密码 spring.datasource.druid.stat-view-servlet.login-password=123 # 设置白名单 spring.datasource.druid.stat-view-servlet.allow=127.0.0.1 # 设置黑名单 spring.datasource.druid.stat-view-servlet.deny=192.168.1.73
访问页面
localhost:8080/druid/index.html 输入登录名和密码,执行一条sql语句,即可看到监控信息。
相关推荐
thunderstorm 2020-06-06
nan00zzu 2020-02-11
suixinsuoyu 2019-12-28
xiaoxiangyu 2019-12-09
韩学敏 2019-11-09
数据库大师兄 2015-09-25
杜鲁门 2020-11-05
yunzhonmghe 2020-08-07
Rain 2020-06-25
咻pur慢 2020-06-18
仰起嘴角 2020-05-27
吾日五省我身 2020-05-12
baobaozai 2020-04-30
GechangLiu 2020-04-26
heywakeup 2020-04-23
jaylong 2020-03-23
shisongsong 2020-03-11
chognzhihongseu 2020-03-06