码迷,mamicode.com
首页 > 数据库 > 详细

Druid监控Mybatis不显示SQL问题

时间:2016-12-22 07:12:36      阅读:413      评论:0      收藏:0      [点我收藏+]

标签:监控   connect   不可用   drive   ppi   static   val   ini   table   

 一、Web.xml增加如下配置:
1、DruidWebStatFilter。如果没有配置filter信息。session监控,web监控等不可用。没有配置

    <filter>  
            <filter-name>DruidWebStatFilter</filter-name>  
            <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>  
            <init-param>  
                <param-name>exclusions</param-name>  
                <param-value>/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</param-value>  
            </init-param>  
        </filter>  
        <filter-mapping>  
            <filter-name>DruidWebStatFilter</filter-name>  
            <url-pattern>/*</url-pattern>  
        </filter-mapping>  

2、DruidStatView。如果没有servlet,无法通过web页面查看监控数据。

    <servlet>  
            <servlet-name>DruidStatView</servlet-name>  
            <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>  
        </servlet>  
        <servlet-mapping>  
            <servlet-name>DruidStatView</servlet-name>  
            <url-pattern>/druid/*</url-pattern>  
        </servlet-mapping>  

 

二、在Spring中声明Druid数据源

    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"  
            init-method="init" destroy-method="close">  
            <property name="driverClassName" value="${jdbc.driverClassName}" />  
            <property name="url" value="${jdbc.url}" />  
            <property name="username" value="${jdbc.username}" />  
            <property name="password" value="${jdbc.password}" />  
            <property name="maxActive" value="${db.maxActive}" />  
            <property name="initialSize" value="${db.initialSize}" />  
            <property name="maxWait" value="${db.maxWait}" />  
            <property name="minIdle" value="${db.minIdle}" />  
            <property name="timeBetweenEvictionRunsMillis" value="${db.timeBetweenEvictionRunsMillis}" />  
            <property name="minEvictableIdleTimeMillis" value="${db.minEvictableIdleTimeMillis}" />  
            <property name="testWhileIdle" value="${db.testWhileIdle}" />  
            <property name="testOnBorrow" value="${db.testOnBorrow}" />  
            <property name="testOnReturn" value="${db.testOnReturn}" />  
            <property name="poolPreparedStatements" value="${db.poolPreparedStatements}" />  
            <property name="maxPoolPreparedStatementPerConnectionSize" value="${db.maxPoolPreparedStatementPerConnectionSize}" />  
            <property name="filters" value="stat" />  
        </bean>  

注意:<property name="filters" value="stat" />属性,不然无法显示SQL检测信息。

Druid监控Mybatis不显示SQL问题

标签:监控   connect   不可用   drive   ppi   static   val   ini   table   

原文地址:http://www.cnblogs.com/sos-blue/p/6209730.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!