忙里偷个闲,在这里分享一下SpringBoot集成Druid实现数据库监控功能,有什么错误欢迎大家指出!
参考文件:
Spring实现Druid监控:https://www.cnblogs.com/wanghuijie/p/druid_monitor.html
DruidDataSource源码分析:https://www.cnblogs.com/wanghuijie/p/druiddatasource.html
保存Druid监控日志:https://www.cnblogs.com/wanghuijie/p/druid_stat_log.html
言归正传,看看是怎么实现的吧。
一:引入依赖
1 <!-- Spring Boot的JPA依赖包 --> 2 <dependency> 3 <groupId>org.springframework.boot</groupId> 4 <artifactId>spring-boot-starter-data-jpa</artifactId> 5 </dependency> 6 <!-- Spring Boot的JPA依赖包end --> 7 <!-- druid --> 8 <dependency> 9 <groupId>com.alibaba</groupId> 10 <artifactId>druid</artifactId> 11 <version>1.0.31</version> 12 </dependency> 13 <!-- druid end -->
二:添加druid配置