Spring Boot 2.x[目前使用2.1.x]
Maven 3.5.x[新版]
Eclipse 4.7+[新版]
lombok[Eclipse插件,安装步骤详见 http://lb-chen.cn:9000/article/10]
STS[Eclipse插件,能够快速构建spring boot 的项目,或者可以使用start.spring.io进行构建]
主要依赖【3个】org.springframework.boot spring-boot-starter-parent2.1.1.RELEASE
Spring Boot配置文件配置com.alibaba druid-spring-boot-starter1.1.10 org.springframework.boot spring-boot-starter-webmysql mysql-connector-java
#datasource base config spring.datasource.username=数据库用户名 spring.datasource.password=数据库密码 spring.datasource.url=jdbc:mysql://数据库IP:端口/数据库名称?useUnicode=true&useSSL=false #annoated driverClassName,have [cj] spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.type=com.alibaba.druid.pool.DruidDataSource #druid pool standard config spring.datasource.druid.max-active=30 spring.datasource.druid.initial-size=3 spring.datasource.druid.min-idle=3 spring.datasource.druid.max-wait=12000 spring.datasource.druid.time-between-eviction-runs-millis=60000 spring.datasource.druid.min-evictable-idle-time-millis=30000 spring.datasource.druid.pool-prepared-statements=true spring.datasource.druid.max-open-prepared-statements=30 spring.datasource.druid.validation-query=select 1 from dual spring.datasource.druid.test-while-idle=true spring.datasource.druid.test-on-borrow=false spring.datasource.druid.test-on-return=false #druid extends config #druid sql firewall monitor spring.datasource.druid.filter.wall.enabled=true #druid sql monitor spring.datasource.druid.filter.stat.enabled=true spring.datasource.druid.filter.stat.log-slow-sql=true spring.datasource.druid.filter.stat.slow-sql-millis=10000 spring.datasource.druid.filter.stat.merge-sql=true #druid uri monitor spring.datasource.druid.web-stat-filter.enabled=true spring.datasource.druid.web-stat-filter.url-pattern=/* spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/* #druid session monitor spring.datasource.druid.web-stat-filter.session-stat-enable=true spring.datasource.druid.web-stat-filter.profile-enable=true #druid spring monitor spring.datasource.druid.aop-patterns=com.xcky.* #druid login user config spring.datasource.druid.stat-view-servlet.login-username=root spring.datasource.druid.stat-view-servlet.login-password=root基本测试前提:
加上一些基本操作数据库操作的controller,
然后访问项目: http://ip:端口/druid
然后输入上面配置的用户和密码root即可访问
附2:本项目示范代码及代码示例 示例源代码:https://github.com/XiaoCao1434/shop-druid 示例:http://lb-chen.cn:9005/druid 用户和密码都为root 如果监控台没有任何数据,请访问如下地址再刷新控制台即可4.0.0 org.springframework.boot spring-boot-starter-parent2.1.1.RELEASE com.xcky shop-druid0.1 shop-druid 1.8 com.alibaba druid-spring-boot-starter1.1.10 org.springframework.boot spring-boot-starter-webmysql mysql-connector-javaorg.springframework.boot spring-boot-starter-data-jpaorg.projectlombok lombokprovided org.springframework.boot spring-boot-maven-plugin
http://lb-chen.cn:9005/user/list


![Spring Boot2.x 的Druid连接池配置[附带监控] Spring Boot2.x 的Druid连接池配置[附带监控]](http://www.mshxw.com/aiimages/31/234739.png)
