首页 > 代码库 > 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问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。