zoukankan      html  css  js  c++  java
  • 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="stat" />属性,不然无法显示SQL检测信息。

    标签: Druid, SQL
  • 相关阅读:
    C#中Post和Get提交
    C#实现动态页面静态化
    瀑布流的实现
    jQuery常用方法验证
    eclipse配置PHP开发环境
    数据结构学习
    机器学习实战
    Leetcode_StringToInteger
    网络学习
    leetcode_前期心得
  • 原文地址:https://www.cnblogs.com/libin6505/p/10980616.html
Copyright © 2011-2022 走看看