Springboot druid 监控sql语句

	@ConfigurationProperties(prefix = "spring.datasource")
    @Bean
    public DruidDataSource druid() {

        DruidDataSource druid = new DruidDataSource();
        try {
            druid.setFilters("stat,wall");
        } catch (SQLException ignored) {
        }
        return druid;
    }

添加这个配置就行了

spring:
  datasource:
    name: springboot
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql:///dbname?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&autoReconnect=true
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: xiaoyan

posted on 2019-07-17 16:50  凉云  阅读(1123)  评论(0)    收藏  举报

导航