Springboot Integrated Druid Monitoring

Source: Internet
Author: User

I. Adding dependencies

<dependency>            <groupId>com.alibaba</groupId>            <artifactid>druid</artifactid >            <version>1.1.  6</version>
</dependency>

Using the one above will make SQL Monitor no data. I don't know why.
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.6</version>
</dependency>

Two. Modify the configuration of Druid in Application.properties

Druid:filters:statmax-active: -Initial-size:1Max-wait:30000min-idle:1 Time-between-eviction-runs-millis:60000min-evictable-idle-time-millis:300000Test- while-idle:trueTest-on-borrow:falseTest-on-return:falsePool-prepared-statements:falseMax-open-prepared-statements:-1Remove-abandoned:trueRemove-abandoned-timeout: theWeb-stat-filter-exclusions:'*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*,/download/*,/wj/*,/assets/*'

Three. Writing a document

Druidstatviewservlet.java
@SuppressWarnings ("Serial") @WebServlet (Urlpatterns="/druid/*", InitParams={                //@WebInitParam (name= "Allow", value= "10.238.100.189,127.0.0.1"),//IP Whitelist (no configuration or null, all access is allowed)@WebInitParam (name=" Allow", value="127.0.0.1"),//IP Whitelist (no configuration or null, all access is allowed)@WebInitParam (name="Deny", value="192.168.16.111"),//IP blacklist (deny takes precedence over allow when there is a common)@WebInitParam (name="Loginusername", value="Druid"),//User name@WebInitParam (name="Loginpassword", value="Druid"),//Password@WebInitParam (name="resetenable", value="false")//disable the "Reset All" feature on HTML pages        }) Public classDruidstatviewservlet extends Statviewservlet {}
Druidstatfilter

 @WebFilter filtername= "  Druidwebstatfilter  , Urlpatterns="  /*   "  , InitParams  ={@WebInitParam (name  ="  exclusions   ", Value= " *.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*    ") //  Ignore resource  })  public  class   Druidstatfilter extends Webstatfilter {}  

Four. Add annotations to the program entry @ServletComponentScan used to scan the servlet class

Springboot Integrated Druid Monitoring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.