Druid 監控組件

使用方法css

1:web.xml配置以下:web

<!-- 自動注入請求上下文 -->
<listener>
   <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>


   <!-- 配置 Druid 監控-->
   <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>*.js,*.gif,*.jpg,*.png,*.css,*.ico,*.jsp,/druid/*,/download/*</param-value>
       </init-param>
       <init-param>
           <param-name>sessionStatMaxCount</param-name>
           <param-value>2000</param-value>
       </init-param>
       <init-param>
           <param-name>sessionStatEnable</param-name>
           <param-value>true</param-value>
       </init-param>
       <init-param>
           <param-name>principalSessionName</param-name>
           <param-value>session_user_key</param-value>
       </init-param>
       <init-param>
           <param-name>profileEnable</param-name>
           <param-value>true</param-value>
       </init-param>
   </filter>
   <filter-mapping>
       <filter-name>DruidWebStatFilter</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>
<!-- 配置 Druid 監控信息顯示頁面 -->
<servlet>
    <servlet-name>DruidStatView</servlet-name>
    <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
    <init-param>
        <!-- 容許清空統計數據 -->
        <param-name>resetEnable</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <!-- 用戶名 -->
        <param-name>loginUsername</param-name>
        <param-value>admin</param-value>
    </init-param>
    <init-param>
        <!-- 密碼 -->
        <param-name>loginPassword</param-name>
        <param-value>XXXXXX</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>DruidStatView</servlet-name>
    <url-pattern>/druid/*</url-pattern>
</servlet-mapping>

2:引入依賴spring

<dependency>
    <groupId>com</groupId>
    <artifactId>druid</artifactId>
    <version>1.0.9</version>
</dependency>
相關文章
相關標籤/搜索