Ali Druid data source

Profiles

 datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: root
    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&useUnicode=true&useSSL=false&serverTimezone=UTC
    type: com.alibaba.druid.pool.DruidDataSource

 

Background monitoring page

   @Bean
     public ServletRegistrationBean startViewServlet () {
         // page access address 
        ServletRegistrationBean the bean = new new ServletRegistrationBean ( new new StatViewServlet (), "/ Druid / *" ); 
        the Map <String, String> = the initParams new new the HashMap <> (); 
        initParams.put ( "loginUsername", "ADMIN"); // admin interface login account 
        initParams.put ( "loginPassword", "123456"); // admin interface login password // background who is allowed access to
         // the initParams. put ( "allow", "localhost "): this means that only can access
         //
                


        initParams.put ( "allow", "" ): When is empty or null, which means allowing all access
         // deny: Druid background who refuse access 
        initParams.put ( "the allow", "" ); 

        // set the initialization parameter 
        bean .setInitParameters (the initParams);
         return the bean; 
    }

 

Filter implementation

    @Bean
     public FilterRegistrationBean webStatFilter () { 
        FilterRegistrationBean the bean = new new FilterRegistrationBean (); 
        bean.setFilter ( new new WebStatFilter ()); 

        // Exclusions: setting request which ruled out by filtration, so as not statistically 
        Map <String, String> initParams = new new the HashMap <> (); 
        initParams.put ( "Exclusions", "* .js, CSS *, / Druid / *." ); 
        bean.setInitParameters (the initParams); 

        // "/ *" indicates that all filter requests 
        bean. setUrlPatterns (Arrays.asList ( "/ *" ));
         return the bean; 
    }

 

 

Guess you like

Origin www.cnblogs.com/chenxi-mxj/p/11967850.html
Recommended