Spring Boot集成Druid查看配置是否生效

项目场景:

Spring Boot集成Druid查看配置是否生效


Druid配置:

@Configuration
public class DruidConfig {
    @Bean
    @ConfigurationProperties("spring.datasource.druid")
    public DataSource druidDataSource(){
        return new DruidDataSource();
    }
}
# druid配置
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.type = com.alibaba.druid.pool.DruidDataSource
spring.datasource.druid.url = jdbc:mysql://127.0.0.1:8306/wuxizw1?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8
spring.datasource.druid.username = test
spring.datasource.druid.password = test&pass

#spring boot默认是不注入这些属性值的,需要自己绑定
spring.datasource.druid.filter.stat.log-slow-sql = true
spring.datasource.druid.filter.stat.slow-sql-millis = 1000
spring.datasource.druid.min-evictable-idle-time-millis = 300000
spring.datasource.druid.test-on-borrow = false
spring.datasource.druid.filter.stat.merge-sql = false
spring.datasource.druid.test-on-return = false
spring.datasource.druid.initial-size = 10
spring.datasource.druid.min-idle = 10
spring.datasource.druid.max-wait = 60000
spring.datasource.druid.pool-prepared-statements = true
spring.datasource.druid.test-while-idle = true
spring.datasource.druid.validation-query = select 1 from dual
spring.datasource.druid.filter.wall.config.multi-statement-allow = true
spring.datasource.druid.time-between-eviction-runs-millis = 60000
spring.datasource.druid.max-pool-prepared-statement-per-connection-size = 20
spring.datasource.druid.max-active = 100
spring.datasource.druid.stat-view-servlet.enabled = true
spring.datasource.druid.stat-view-servlet.url-pattern = /druid/*

查看是否生效:

配置完druid后,不知道是否已经生效,我们可以修改某个属性的值,然后在http://localhost:8080/druid监控页面,查看值是否有改变。

打开http://localhost:8080/druid监控页面,点击“数据源”,就可以看到相关配置:

Spring Boot集成Druid查看配置是否生效_第1张图片

 这时候我们改变某个属性的值,比如:

spring.datasource.druid.stat-view-servlet.url-pattern = /druid.test/*

这时候访问地址就变成:http://localhost:8080/druid.test

证明配置是生效的

你可能感兴趣的:(Spring,spring,boot,druid,datasource,druid配置,druid是否生效)