zoukankan      html  css  js  c++  java
  • druid 配置监控页面和开启防火墙,spring

    1. dataSource中增加

    <property name="filters" value="stat,wall"/>

    2. spring 中增加(spring的支持)

    <!-- druid spring monitor setting -->
    <!-- 开启@AspectJ AOP代理 -->
        
        <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"/>
        <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
            <property name="patterns">
                <list>
                    <value>com.beta.mss.core.service.*</value>
                </list>
            </property>
        </bean>
        <aop:config proxy-target-class="true">
            <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut"/>
        </aop:config>

    需要注意的是这里的patterns中一般只监控service,controller监控不到,同时spring代理使用CGLib的代理方式,但是CGLib不能代理final类或被private,final修饰的方法,CGLib面对具体代理类,不能是接口,jdk的代理是面向接口的。

    3. web.xml

    <!-- druid url monitor setting start -->
    <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,/druid/*</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 url monitor setting end -->
    <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>name</param-value>  
            </init-param>  
            <init-param>  
                密码  
                <param-name>loginPassword</param-name>  
                <param-value>pwd</param-value>  
            </init-param>   -->
        </servlet>
        <servlet-mapping>
            <servlet-name>DruidStatView</servlet-name>
            <url-pattern>/druid/*</url-pattern>
        </servlet-mapping>
  • 相关阅读:
    什么是.NET Core以及.NET Core能做什么 菜鸟飞不动
    SQL数据库连接字符串的几种写法整理
    高并发
    前端 防抖&节流,你学到未啊?
    Promise实现一个函数,通过fetch请求一个接口'/api/getdata'(可能成功,也可能失败),超过3秒钟请求未返回则认为超时
    手写实现deepClone方法
    手写Promise.retry方法;实现次数内重试请求
    element-ui的table表格通过子表数据,进行展示左侧展开箭头
    页面导出为PDF格式
    js自定义数字跳动效果computeNumber
  • 原文地址:https://www.cnblogs.com/yangfei-beijing/p/8527611.html
Copyright © 2011-2022 走看看