This article mainly introduces how to solve SpringBoot Integrate Druid after sql No data for monitoring
If necessary , You can refer to
If it helps , Not forget Give the thumbs-up ❥

<> First we need to integrate Druid

*
<> stay pom.xml Introduce dependency in
<!-- set up data sources The default is to use springboot Medium jdbc Connection pool --> <dependency> <groupId>com.alibaba</
groupId> <artifactId>druid</artifactId> <version>1.1.16</version> </dependency>
*
<> configuration parameter
# Specify connection pool type spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
# Connection pool configuration information # Initialize size , Minimum , Maximum spring.datasource.initalSize=5
spring.datasource.maxActive=20 spring.datasource.minIdle=5 # Configure the timeout time for getting connection waiting
spring.datasource.maxWait=60000 # Configure the minimum lifetime of a connection in the pool , In milliseconds
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=SELECT 1 FROM DUAL
spring.datasource.testWhileIdle=true spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
*
<> Create a Druid Configuration class for
// This annotation is used to declare that this class is a configuration class @Configuration public class DruidConfig {
@ConfigurationProperties(prefix = "spring.datasource") //
Used to scan configuration files with prefix spring.datasource Configuration information for @Bean // Used to register to the configuration container public DataSource druid()
{ return new DruidDataSource(); } // To configure Druid Monitoring of // Configure a management background Servlet @Bean public
ServletRegistrationBeanstatViewServlet() { ServletRegistrationBean
servletRegistrationBean= new ServletRegistrationBean(new StatViewServlet(),
"/druid/*"); Map<String,String> initParam = new HashMap<>(); initParam.put(
"loginUsername","admin"); initParam.put("loginPassword","123456"); initParam.put
("allow",""); // The default is to allow all access initParam.put("deny",""); // Default access
servletRegistrationBean.setInitParameters(initParam); return
servletRegistrationBean; } // Sign up for one filters @Bean public FilterRegistrationBean
druidStatFilter(){ FilterRegistrationBean filterRegistrationBean = new
FilterRegistrationBean(new WebStatFilter()); // Add filter rule . filterRegistrationBean.
addUrlPatterns("/*"); // Add formatting information that does not need to be ignored . filterRegistrationBean.addInitParameter(
"exclusions","*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); return
filterRegistrationBean; } }
<> In this way, we can configure it Druid

*
<> Launch project , Visit localhost: Port number /druid, Jump to login page , Use the configured admin and 123456 Sign in

*
<> And that's the problem , We are druid Manage the sql No data in monitoring

*
<> Solution

* Add to configuration parameters # Configure monitoring statistics intercepted filters, Monitoring interface after removal sql Will not be able to count spring.datasource.filters : stat
* Then start the project , Visit again druid Management page of , Now you can see sql There's data in the surveillance

* In this way, we can solve the problem successfully sql Monitoring issues , If there is still a problem, check it pom Dependencies in documents .

Technology
©2019-2020 Toolsou All rights reserved,
Huawei 2021 session Hardware Engineer Logical post (FPGA) Super detailed surface !!!Vue-element-admin upgrade ui edition virtual machine VMware Download and install the most detailed tutorial !C++ Move constructor and copy constructor sound of dripping water java Backstage interview pygame Realize full screen mode and adjustable window size mysql Database setting character set configuration modification my.ini file (windows)30 What's the experience of being a junior programmer at the age of 20 C++ Multithreading programming ( Summary of common functions and parameters )python_ cherry tree