-class-name: org.gjt.mm.mysql.Driver #配置MySQL的驱动程序类
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
username: root
password:123456filters: stat,wall,log4j #druid监控配置
dbcp2:
min-idle: 5#数据库连接池的最小维持连接数
initial-size: 5#初始化提供的连接数
max-total: 5#最大的连接数
max-wait-millis: 200 #等待连接获取的最大超时时间
3.最后,还需要增加一个druid的基本配置,这里直接上代码。
importjavax.sql.DataSource;importorg.springframework.boot.context.properties.ConfigurationProperties;importorg.springframework.boot.web.servlet.FilterRegistrationBean;importorg.springframework.boot.web.servlet.ServletRegistrationBean;importorg.springframework.context.annotation.Bean;importorg.springframework.context.annotation.Configuration;importcom.alibaba.druid.pool.DruidDataSource;importcom.alibaba.druid.support.http.StatViewServlet;importcom.alibaba.druid.support.http.WebStatFilter;
@