Springboot druid监控配置

@Configuration
public class DataSourceConfig {

    @Bean
    public ServletRegistrationBean statViewServlet(){
        ServletRegistrationBean bean =  new ServletRegistrationBean(new StatViewServlet(),"/druid/*");
        Map<String, String> initMap = new HashMap<>();
        initMap.put(StatViewServlet.PARAM_NAME_JMX_USERNAME,"admin");
        initMap.put(StatViewServlet.PARAM_NAME_JMX_PASSWORD,"123456");
        initMap.put("loginUsername", "admin");
        initMap.put("loginPassword", "123456");

        bean.setInitParameters(initMap);
        return bean;
    }

    @Bean
    public FilterRegistrationBean webStatFilter(){
        FilterRegistrationBean bean = new FilterRegistrationBean();
        bean.setFilter(new WebStatFilter());
        Map<String, String> initMap = new HashMap<>();
        bean.setInitParameters(initMap);
        bean.setUrlPatterns(Arrays.asList("/*"));
        return bean;
    }
}

 

posted @ 2018-05-26 07:42  梦见舟  阅读(286)  评论(0编辑  收藏  举报