首页 > 代码库 > Druid监控Mybatis不显示SQL问题

Druid监控Mybatis不显示SQL问题

 一、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="http://www.mamicode.com/stat" />属性,不然无法显示SQL检测信息。

Druid监控Mybatis不显示SQL问题